Your problem is your naming conventions. VB is not case sensitive like c# so naming your click handlers the same as your buttons is a big no-no. Try changing your code and remember to be more descriptive in your naming conventions.
<script runat="server">
Sub click_submit(ByVal sender As Object, ByVal e As System.EventArgs)
name.Text = "Good Morning " & txt1.Text & "!"
End Sub
Sub click_clear(ByVal sender As Object, ByVal e As System.EventArgs)
txt1.Text = String.Empty
name.Text = String.Empty
End Sub
</script>
<body>
<h2>
Contact
</h2>
<form id="Form1" runat="server">
Your name: <asp:TextBox id="txt1" runat="server" />
<asp:Button ID="bttnSubmit" OnClick="click_submit" Text="Submit" runat="server" />
<asp:Button ID="bttnClear" OnClick="click_clear" Text="Clear" runat="server" />
<p><asp:Label id="name" runat="server" Text="Name" /></p>
Marked as answer by psha85 on Apr 21, 2010 05:44 PM
asgradl84
Member
609 Points
113 Posts
Re: please help
Apr 20, 2010 09:25 PM|LINK
Your problem is your naming conventions. VB is not case sensitive like c# so naming your click handlers the same as your buttons is a big no-no. Try changing your code and remember to be more descriptive in your naming conventions.
<script runat="server"> Sub click_submit(ByVal sender As Object, ByVal e As System.EventArgs) name.Text = "Good Morning " & txt1.Text & "!" End Sub Sub click_clear(ByVal sender As Object, ByVal e As System.EventArgs) txt1.Text = String.Empty name.Text = String.Empty End Sub </script> <body> <h2> Contact </h2> <form id="Form1" runat="server"> Your name: <asp:TextBox id="txt1" runat="server" /> <asp:Button ID="bttnSubmit" OnClick="click_submit" Text="Submit" runat="server" /> <asp:Button ID="bttnClear" OnClick="click_clear" Text="Clear" runat="server" /> <p><asp:Label id="name" runat="server" Text="Name" /></p>