简体   繁体   English

RadioButtonList SelectedIndexChanged并非每次都触发

[英]RadioButtonList SelectedIndexChanged not firing everytime

I have a RadioButtonList control in asp.net UserControl. 我在asp.net UserControl中有一个RadioButtonList控件。 It has 2 Radio buttons "Leave" and "Available". 它具有2个单选按钮“ Leave”和“ Available”。 On click of Leave, I display alert from SelectedIndexChanged event as "Are you sure you want to take Leave?" 单击“请假”时,我将显示来自SelectedIndexChanged事件的警报为“您确定要请假吗?” with Ok and Cancel buttons. 单击确定和取消按钮。 On click of Cancel, it will automatically select "Available". 单击“取消”后,它将自动选择“可用”。 Upto this it is fine. 到目前为止,这很好。

Step 1: User Clicks Cancel restores to "Available" 步骤1:用户单击“取消”(Cancel)恢复到“可用”(Available)

Step 2: When User again clicks "Leave", it will not display alert from SelectedIndexChanged of RadioButton. 步骤2:当用户再次单击“离开”时,它将不会显示来自RadioButton的SelectedIndexChanged的警报。

Step 3: Now it will work again. 第3步:现在它将再次起作用。

For this I have enabled EnableViewState="true" for that UserControl. 为此,我已为该UserControl启用EnableViewState =“ true”。 But still it does not work for the 2nd time. 但是仍然无法第二次使用。

Below is the Server side SelectedIndexChanged event 下面是服务器端的SelectedIndexChanged事件

protected void rdlUser_SelectedIndexChanged(object sender, EventArgs e)
{
    if (rdlUser.SelectedIndex == 1)
    {
        txtUser.Enabled = true;
    }
    else
    {
        radWindowManager.RadConfirm("Are you sure you want to take Leave?", "confirmSave" + this.ClientID, 300, 100, null, "");
    }
}

This is the javascript code 这是JavaScript代码

function confirmSave<%=this.ClientID%>(arg) {
    if (arg == true) {

        $find('<%= FindControl("txtUser").ClientID %>').set_value("");

    }
    else {
        var rdlUser = document.getElementById("<%= rdlUser.ClientID %>");
        var radioButtons = rdlUser.getElementsByTagName('input');
        radioButtons[3].checked = true;
    }
}

Use the following code and let me know the result 使用以下代码,让我知道结果

function confirmSave<%=this.ClientID%>(arg) {
    if (arg == true) {
        $find('<%= FindControl("txtUser").ClientID %>').set_value("");
        return true;
    }
    else {
        var rdlUser = document.getElementById("<%= rdlUser.ClientID %>");
        var radioButtons = rdlUser.getElementsByTagName('input');
        radioButtons[3].checked = true;
        return false;
    }
}

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

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