Newbie Question

  • Thread starter Thread starter Bijoy Naick
  • Start date Start date
B

Bijoy Naick

I am new to .net and have a question about a very simple aspx page.

I have a form in the body section of my page..

<form runat="server">
<asp:Button ID="Go" Runat="server" Text="Go"/>
<br>
<asp:Label text="Default" ID="UserName" Runat="server"/>
</form>

In teh head section of the page, I have the following script

<script language="vb" runat="server">
Sub Go_Click(Source As Object, E as EventArgs)
UserName.Text = "Querying"
End Sub
</script>

When the page loads in the browser, I see the Go button and the text
"Default" below it. However, when I click the Go button nothing
happens. Shouldn't the text "default" change to "Querying"??
 
You'll have to add either an onClick="Go_Click" to the asp:button
<asp:Button ID="Go" Runat="server" onClick="Go_Click" Text="Go"/>
or
in the code add a handles event to the sub, for example
<script language="vb" runat="server">
Sub Go_Click(Source As Object, E as EventArgs) handles Go.Click
UserName.Text = "Querying"
End Sub
</script>
 
Forget that about the "Handles" option, you'd have to do more to get that
working, for now since you are new, just use the first method.
 
Back
Top