简体   繁体   English

已检查的更改事件未触发

[英]Checked change event is not firing

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" />
                        &nbsp;&nbsp;
        <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 谢谢

set AutoPostBack="true" 设置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" />
                        &nbsp;&nbsp;
        <asp:RadioButton ID="following" runat="server" ForeColor="Black" Text="Following" GroupName="rd2" OnCheckedChanged="following_CheckedChanged" AutoPostBack="true" />

You need to add AutoPostBack="true" . 您需要添加AutoPostBack="true"

Change the aspx code to as below: 将aspx代码更改为如下所示:

<asp:RadioButton AutoPostBack="true" ID="submitter" runat="server" GroupName="rd2" OnCheckedChanged="submitter_CheckedChanged" Text="Submitter" />
                        &nbsp;&nbsp;
<asp:RadioButton AutoPostBack="true" ID="following" runat="server" ForeColor="Black" Text="Following" GroupName="rd2" OnCheckedChanged="following_CheckedChanged" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM