This is a migrated thread and some comments may be shown as answers.

SelectedIndexChanged on <asp:RadioButtonList>

3 Answers 337 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lisa
Top achievements
Rank 1
Lisa asked on 17 Jun 2013, 04:33 PM

How can I add a confirmation message "Please confirm that you want to proceed with the selected value. Click OK to proceed." when rb1 value is changed? If user clicks OK then it should execute rb1_SelectedIndexChanged, otherwise it should not.

<asp:RadioButtonList ID="rb1" runat="server" OnSelectedIndexChanged="rb1_SelectedIndexChanged" AutoPostBack="true">
                        <asp:ListItem Value="1">1</asp:ListItem>
                        <asp:ListItem Value="0">0</asp:ListItem>  
</asp:RadioButtonList>
  
code behind:
protected void rb1_SelectedIndexChanged(Object sender, EventArgs e)
    {                               
           --call a stored procedure to update the database with the newly selected  rb1.Value
    }

3 Answers, 1 is accepted

Sort by
0
Lisa
Top achievements
Rank 1
answered on 18 Jun 2013, 02:35 AM
Any suggestions/samples please?
0
Accepted
Shinu
Top achievements
Rank 2
answered on 18 Jun 2013, 06:37 AM
Hi,

Try the following code to achieve the scenario.

ASPX:
<asp:RadioButtonList ID="rb1" runat="server" onclick="return clickfn()" OnSelectedIndexChanged="rb1_SelectedIndexChanged" AutoPostBack="true">
      <asp:ListItem Value="1">1</asp:ListItem>
      <asp:ListItem Value="0">0</asp:ListItem
</asp:RadioButtonList>

JS:
function clickfn()
{
   var ok = confirm("Are you sure?")
    if (ok)
        return true; // will fire server side selectedindexchanged event
    else
      return false;
}

Thanks,
Shinu.
0
Lisa
Top achievements
Rank 1
answered on 18 Jun 2013, 12:15 PM
Thank you for your response. I am trying your solution and will see it works.
Tags
Grid
Asked by
Lisa
Top achievements
Rank 1
Answers by
Lisa
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or