ASP.NET - how to radibuttonlist uncheck - Asked By msakt on 06-Jun-12 02:40 AM

how to radibuttonlist uncheck....in code dont script


after insert radiobuttonlist is uncheck
Somesh Yadav replied to msakt on 06-Jun-12 02:50 AM

You can do like this...

<asp:RadioButtonList ID="rbl1" runat="server">

<asp:ListItem Text="A" Selected="True"></asp:ListItem>

<asp:ListItem Text="B"></asp:ListItem>

<asp:ListItem Text="C"></asp:ListItem>

</asp:RadioButtonList>

<asp:Button ID="btnReset" runat="server" Text="Reset" OnClientClick="return resetFun();" /> 

<script type="text/javascript">
       
function resetFun() {
           
var radioButtons = document.getElementsByName('<%=rbl1.ClientID%>');
           
for (var x = 0; x < radioButtons.length; x++) {
               
if (radioButtons[x].checked) {
                    radioButtons
[x].checked = false;
                   
return false;
               
}
           
}
       
}
     
</script>   </script>
 
Jitendra Faye replied to msakt on 06-Jun-12 02:53 AM
Use this code-

radibuttonlist.SelectedIndex=-1;
 
Neha Garg replied to msakt on 06-Jun-12 02:54 AM
hi ..


See the below code:

protected void Button1_Click (object sender, EventArgs e)
 {
   RadioButtonList1.ClearSelection();
 }
Chintan Vaghela replied to msakt on 06-Jun-12 02:56 AM

Hi Frndz,

 

Call followng javascript for Uncheck radio button list on button click evetn

 

function UncheckRadioButotnList() {

 

      var rbList = document.getElementById("<%= radioButtonList.ClientID %>");//Pass your radion button list id

 

      var radio = rbList.getElementsByTagName("input");

    

 

      for (var i = 0; i < radio.length; i++) {

        if (radio[i].checked) {

          radio[i].checked = false;

        }

      }

    }

 

 

Hope this helpful!

Thanks

 

 

 

 

Chintan Vaghela replied to msakt on 06-Jun-12 02:59 AM

Hi Frndz,

 

After insert operation call following code for uncheck all item

 

 

  // After insert call following code

        foreach (ListItem item in rbl.Items)

        {

          item.Selected = false;

        }

 

Hope this helpful!

Thanks

 

 

 

 

DL M replied to msakt on 06-Jun-12 03:09 AM
Hi..

RadioButtonList1.ClearSelection() will set the selected property of the items of the radiobuttonlist to false.