Hey guys,
I have a question about wiring web server controls. From many of the examples that I have seen the event handler has been declared with a private access modifier. I tried doing so as shown:
<asp:Label runat="server" ID="lblMessage" Font-Names="Verdana" Text="Hello" />
<br />
<asp:Button runat="server" ID="btnSubmit" text="click me!" onClick="btnSubmit_Click" />
and in the code behind file:
private void btnSubmit_Click(object sender, EventArgs e)
{
lblMessage.Text = "Goodbye";
}
But the compiler is unable to locate the click handler unless i change the access to protected.
Should button event handlers ever be private, and if so, why did it not work in my instance?
Also, other than using the onClick property, are there any other methods for wiring event handlers to controls that are declaratively created in the .aspx file?
Thanks in advance, Yong