name 'a' is not declared

  • Thread starter Thread starter Ben
  • Start date Start date
B

Ben

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
 
Ben said:
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.
 
Back
Top