Click here to Skip to main content
16,017,015 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have a 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" />
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
    </p>
    <p>
        &nbsp;</p>
    <p>
    </p>
</asp:Content>


and CS page
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
      //
    }
    protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
    {
//code block
    }
    protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
    {
//code block
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        RadioButton2.Checked = true;
    }
}


its my requirement that radio button 1 is checked during page load and when button pressed it change to unchecked and radio button 2 is checked.my problem is after pressing button checked change event is not firing..plzz help.........
Posted

1 solution

i solve this by changing my button click
C#
protected void Button1_Click(object sender, EventArgs e)
  {
      RadioButton2.Checked = true;
      RadioButton1.Checked = false;
  }

is this a good one.why radio button show such behaviour
 
Share this answer
 

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