//global object for radiobutton1 is created for access all over to form static RadioButton RadioButton1 = new RadioButton(); //here i am assinging in particular div which id is "RadioDiv1" Control myControl1 = FindControl("RadioDiv1"); myControl1.Controls.Add(RadioButton1); RadioButton1.Enabled = true; RadioButton1.EnableViewState = true; RadioButton1.AutoPostBack = false; RadioButton1.ID = "RadioButton1"; myControl1.Controls.Add(new LiteralControl("")); RadioButton1.CheckedChanged += new EventHandler(RadioButton1_CheckedChanged); //this is the checkedChanged event private void RadioButton1_CheckedChanged(object sender, EventArgs e) { if (!RadioButton1.Checked) { RadioButton1.Checked = true; } else { RadioButton1.Checked = false; } } //But after clicking on the radiobutton1 the checked changed event is not fired, I am checking the value of Radiobutton1.checked == true // even after select it gives me false . string user_ans = ""; if (RadioButton1.Checked == true) { user_ans += "A"; }
you can try a function in autopostback=true
if(!ispostbck) { RadioButton1_CheckedChanged(this,null); }
it may help you..
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)