1

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**

CPK_2011
  • 872
  • 3
  • 21
  • 57

1 Answers1

0

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

Community
  • 1
  • 1
rdmptn
  • 5,413
  • 1
  • 16
  • 29
  • I have a problem here. The Radiobuttons "Available" and "Leave" of RadiobuttonList are coming from database. It can be more than 2 values("Available" & "Leave"). I need to identify that in client javascript and set the value of it programatically. I need to use similar code like this because it is a UserControl `$find('<%= FindControl("txtUser").ClientID %>')` – CPK_2011 Oct 04 '16 at 17:15
  • use unique names for the JS functions (http://www.telerik.com/support/kb/aspnet-ajax/details/using-dynamic-unique-names-for-javascript-functions) and inject the needed ID with a server code block in each instance – rdmptn Oct 25 '16 at 14:28