Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > name 'a' is not declared

Reply
Thread Tools

name 'a' is not declared

 
 
Ben
Guest
Posts: n/a
 
      08-23-2009
Hi,

in code-behind, i have:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim a As Integer
a = 5
End Sub

i want to use that variable in the aspx file:

<body>
<form id="form1" runat="server">
<%=a%>
</form>
</body>

but i get the error: name 'a' is not declared.

Where and how do i have to declare 'a'?

Thanks
Ben



 
Reply With Quote
 
 
 
 
Ben
Guest
Posts: n/a
 
      08-24-2009
both, but i found it by myself: instead of DIM, just FRIEND as declaration.

"Mark Rae [MVP]" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> "Ben" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> I want to use that variable in the aspx file:
>>
>> <body>
>> <form id="form1" runat="server">
>> <%=a%>
>> </form>
>> </body>
>>
>> but I get the error: name 'a' is not declared.

>
> Yes, you would do...
>
>
>> Where and how do I have to declare 'a'?

>
> You'll need to define what you mean by "use that variable in the aspx
> file"... Do you mean that you want to populate a DOM element's value with
> the server-side variable? Or do you mean that you want to use the
> server-side variable in e.g. a client-side script...?
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net



 
Reply With Quote
 
 
 
 
Göran Andersson
Guest
Posts: n/a
 
      08-25-2009
Ben wrote:
> Hi,
>
> in code-behind, i have:
>
> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
> Handles Me.Load
> Dim a As Integer
> a = 5
> End Sub
>
> i want to use that variable in the aspx file:
>
> <body>
> <form id="form1" runat="server">
> <%=a%>
> </form>
> </body>
>
> but i get the error: name 'a' is not declared.
>
> Where and how do i have to declare 'a'?
>
> Thanks
> Ben
>


You are declaring the variable as local in the method. To access if from
the aspx code you have to declare it as a protected (or public) member
of the class intead.

--
Göran Andersson
_____
http://www.guffa.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
declared or not declared ? JohnZing ASP .Net 3 02-05-2006 08:38 PM
Name is not declared DC Gringo ASP .Net 1 02-27-2004 02:40 PM
Name <whatever> not declared?!?!?! Aaargh!! Scott M. ASP .Net 2 02-05-2004 06:18 PM
"name not declared" but it is TJS ASP .Net 2 02-03-2004 11:47 PM
Name 'DiffGram' is not declared. Guoqi Zheng ASP .Net 0 01-12-2004 04:42 PM



Advertisments