Page doesn't postback after clicking OK in confirm box for Radiobuttonlist
<p>I have a RadioButtonList with 2 items. I want a postback when any of the items is selected. I have added a confirm box for one item of RadioButtonList. But, when I click OK in the confirmbox, there is no postback and SelectedIndexChanged event is not getting fired.</p>

<p>AutoPostback property of RadioButtonList is set to true.
This is a code fragment from my Page_Load method:</p>

<pre><code>RadioButtonOpenRestricted.Attributes.Add("AutoPostBack", "True");
RadioButtonOpenRestricted.Items.FindByValue("Open Access").Attributes.Add("AutoPostBack", "True");
RadioButtonOpenRestricted.Items.FindByValue("Open Access").Attributes.Add("OnClick", "javascript:return confirm('Are you sure?');");
</code></pre>

<p>Earlier, I had added confirm box for entire RadioButtonList and postback was working as expected. But I want the confirm box to be displayed only when user clicks on "Open Access" item.</p>

<p>Please help!</p>

<hr>

<p>I tried a few things. The new code lines look like:</p>

<p>RadioButtonOpenRestricted.Items.FindByValue("Open Access").Attributes.Add("OnClick", "javascript:showConfirmBox(0,'" + RadioButtonOpenRestricted.ClientID + "')");
        RadioButtonOpenRestricted.Items.FindByValue("Restricted Access").Attributes.Add("OnClick", "javascript:showConfirmBox(1,'" + RadioButtonOpenRestricted.ClientID + "')");</p>

<p>The javascript method is:</p>


    function showConfirmBox(i,id) 
    {
        if(i==0)
        {
            if (confirm("Are you sure you want to provide Open Access? All existing individual permissions will be removed!")==true)
            {
                var ctrl1 = document.getElementById(id + "_0");
                ctrl1.selected=true;
            }
            else
            {
                var ctrl2 = document.getElementById(id + "_1");
                 ctrl2.selected=true;
            }
        }
        if(i==1)
        {
            var ctrl2 = document.getElementById(id + "_1");
            ctrl2.selected=true;
        }
    }


<p>The problem with this code is that it is treating both OK and Cancel as same. The confirm box is getting displayed but if-else part of the javascript method is not getting called. I tried using OnClientClick also...this doesnt even display the Confirmbox.</p>

<p>Help!!!</p>
