Reputation: 404
I want to enable and disable textfields on checked change event but this event is not firing. Following is my radio button code
<asp:RadioButton ID="submitter" runat="server" GroupName="rd2" OnCheckedChanged="submitter_CheckedChanged" Text="Submitter" />
<asp:RadioButton ID="following" runat="server" ForeColor="Black" Text="Following" GroupName="rd2" OnCheckedChanged="following_CheckedChanged" />
Following is my checked change event code
protected void following_CheckedChanged(object sender, EventArgs e)
{
if (submitter.Checked == true)
{
contactName.Enabled = false;
Contactmail.Enabled = false;
Response.Write("<script LANGUAGE='JavaScript' >alert('following event submitter check')</script>");
}
if (following.Checked == true)
{
contactName.Enabled = true;
Contactmail.Enabled = true;
Response.Write("<script LANGUAGE='JavaScript' >alert('following event following check')</script>");
}
}
protected void submitter_CheckedChanged(object sender, EventArgs e)
{
if (submitter.Checked == true)
{
contactName.Enabled = false;
Contactmail.Enabled = false;
Response.Write("<script LANGUAGE='JavaScript' >alert('submitter event submitter check')</script>");
}
if (following.Checked == true)
{
contactName.Enabled = true;
Contactmail.Enabled = true;
Response.Write("<script LANGUAGE='JavaScript' >alert('submitter event following check')</script>");
}
Please tell me where is problem. thanks
Upvotes: 1
Views: 44
Reputation: 10285
set AutoPostBack="true"
Postback means sending Data to server. It will execute server side events. for more Details Click Here
<asp:RadioButton ID="submitter" runat="server" GroupName="rd2" OnCheckedChanged="submitter_CheckedChanged" Text="Submitter" AutoPostBack="true" />
<asp:RadioButton ID="following" runat="server" ForeColor="Black" Text="Following" GroupName="rd2" OnCheckedChanged="following_CheckedChanged" AutoPostBack="true" />
Upvotes: 2
Reputation: 2202
You need to add AutoPostBack="true"
.
Change the aspx code to as below:
<asp:RadioButton AutoPostBack="true" ID="submitter" runat="server" GroupName="rd2" OnCheckedChanged="submitter_CheckedChanged" Text="Submitter" />
<asp:RadioButton AutoPostBack="true" ID="following" runat="server" ForeColor="Black" Text="Following" GroupName="rd2" OnCheckedChanged="following_CheckedChanged" />
Upvotes: 2