G
Grey Alien
I have manually added two radio button controls to my Asp.Net webpage
(*.aspx file - souce view). This is the code I added:
(I have not included the <%@PAGE directive and <div></div> for brevity sake)
<asp:RadioButton
ID ="rbtn1"
GroupName = "grp1"
OnCheckedChanged = "RadioButton_CheckedChanged"
Text = "Option 1"
runat="server" />
<asp:RadioButton
ID ="rbtn2"
GroupName = "grp1"
OnCheckedChanged = "RadioButton_CheckedChanged"
text="Option 2"
runat="server" />
What I find suprising is that although I have AutoEventWireup="true" in
my %@PAGE directive, I find that I still have to hand write the event
handlers for the asp controls that I add (why?)
Secondly, I succesfully manually added a Button1_Click event handler for
a button control that I added, and that compiled successfully. However,
when I added the ff event handler for the RadioButton:
protected void RadioButton_CheckChanged(Object sender, EventArgs e)
{
RadioButton rbtn = (RadioButton)sender;
if (String.Compare(rbtn.ID, "Option 1") == 0 )
TextBox1.Text = "Option 1";
else
TextBox1.Text = "Option 2";
}
I got the ff error when compiling :
Error 1 'ASP.default_aspx' does not contain a definition for
'RadioButton_CheckedChanged' C:\projects\websites\testsite\Default.aspx 37
can anyone spot what I may be doing wrong ?
(*.aspx file - souce view). This is the code I added:
(I have not included the <%@PAGE directive and <div></div> for brevity sake)
<asp:RadioButton
ID ="rbtn1"
GroupName = "grp1"
OnCheckedChanged = "RadioButton_CheckedChanged"
Text = "Option 1"
runat="server" />
<asp:RadioButton
ID ="rbtn2"
GroupName = "grp1"
OnCheckedChanged = "RadioButton_CheckedChanged"
text="Option 2"
runat="server" />
What I find suprising is that although I have AutoEventWireup="true" in
my %@PAGE directive, I find that I still have to hand write the event
handlers for the asp controls that I add (why?)
Secondly, I succesfully manually added a Button1_Click event handler for
a button control that I added, and that compiled successfully. However,
when I added the ff event handler for the RadioButton:
protected void RadioButton_CheckChanged(Object sender, EventArgs e)
{
RadioButton rbtn = (RadioButton)sender;
if (String.Compare(rbtn.ID, "Option 1") == 0 )
TextBox1.Text = "Option 1";
else
TextBox1.Text = "Option 2";
}
I got the ff error when compiling :
Error 1 'ASP.default_aspx' does not contain a definition for
'RadioButton_CheckedChanged' C:\projects\websites\testsite\Default.aspx 37
can anyone spot what I may be doing wrong ?