Click here to Skip to main content
15,900,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have an aspx page
XML
<%@ Page Title="" Language="C#" MasterPageFile="~/UserArea/MainMaster.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <p>
        <br />
        <asp:RadioButton ID="RadioButton1" runat="server" AutoPostBack="True"
            Checked="True" GroupName="a" oncheckedchanged="RadioButton1_CheckedChanged" />
        <asp:RadioButton ID="RadioButton2" runat="server" AutoPostBack="True"
            GroupName="a" oncheckedchanged="RadioButton2_CheckedChanged" />
    </p>
    <p>
    </p>
</asp:Content>

and c# file
C#
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        RadioButton2.Checked = true;
    }
    protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
    {
//code block
    }
    protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
    {
//code block
    }
}


event radio button checked change is not fired when i clicked on the radio button .plz help.i suffer same problem in edit mode of another page.
Posted
Comments
rajin kp 2-May-13 0:59am    
see question
http://www.codeproject.com/Questions/586472/radioplusbuttonplusgroupplus-3apluseventplusisplus

if you want the radiobutton1 to be checked by default then you can remove the code on page load to set the radiobutton2 checked as true that should fire the event.

Since the checked property is set to true for both the radiobuttons (in page load and the aspx page) the checkedchanged event is not being fired.


Thank you
Hari
 
Share this answer
 
Comments
venumadhav.narla777 2-May-19 10:24am    
Thanq Saved my day
I tried your code. When i remove the default value for checked property for Radiobutton1 then the event fires properly. Please try this for Radiobutton1
VB
<asp:RadioButton ID="RadioButton1" runat="server" AutoPostBack="True"
GroupName="a" oncheckedchanged="RadioButton1_CheckedChanged" />
 
Share this answer
 
Comments
rajin kp 2-May-13 0:46am    
i cant remove default checked property its requirement in my application.During edit mode some times radio button 1 is checked sometimes radio button is checked. consider that first load as edit mode

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900