简体   繁体   中英

Restore previous state of RadiobuttonList in asp.net

I have a RadioButtonList in asp.net Usercontrol. It contains the values "Leave", "Available". When the user clicks "Leave", then, I should display message as "Are you sure you want to take Leave?" with "Ok" and "Cancel" buttons.

When the user clicks Available/Leave, then the following event fires.

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

This is Client side javascript function...

function confirmSave<%=this.ClientID%>(arg) {
    if (arg == true) {
        $find('<%= FindControl("txtUser").ClientID %>').set_value("User has taken Leave");
}

**If the user clicks Leave Radiobutton and clicks cancel in the confirm message box, then the program should revert the change to "Available" Radiobutton. How can I select that "Available" programatically in Server/Client side?

EDIT:The main goal is to reset the value to previous state**

Add an else statement to catch arg==false and set the checked property of the desired radio input to true . See Check a radio button with javascript

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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