Hi! It may seems easy but since I am learning I would like to know How I can change text of Lable.
I have RadioButtonList(rbl1 and rbl2) and Label1 and when someone click on rbl2, how i can change text of Label1. Also, I have set rbl1 as default selected. So when somone click back to rbl1, the default text of Label1 should be appearing.
Thanks for your answer.
R Patel

Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Aug 11, 2008, 1:02 PM EDT
Go to property and Set the AutoPostBack property to true for the radiobuttonlist.
and try out the following code:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//check the first item of radio button list on first time of page load.
RadioButtonList1.SelectedIndex = 0;
Label1.Text = RadioButtonList1.SelectedItem.Text.ToString();
}
else
{
Label1.Text = RadioButtonList1.SelectedItem.Text.ToString();
}
}
Note: You also can do it by using java script.
Edit: Oh sorry, Ryan replied already while I am sending the post.
Muhammad Shahid Farooq107 reputationPosted Aug 11, 2008, 10:37 AM EDT
write the following code in the click event of rbl1:
Label1.text = "Label1"
write the following code in the click event of rbl2:
Label1.text = "Text Changed"
Pal27 reputationPosted Aug 11, 2008, 10:46 AM EDT
Hi! Muhammad
I have radiobuttonlist and it seems it needs different answer. can you tell me how that can work.
Thanks
R Patel
Ryan AlfordRank #1,411 · 1.2K reputationPosted Aug 11, 2008, 12:54 PM EDT
Label1.Text = "Text Changed";
and of course, if your label is not named "Label1", then you need to put the name of your label there.
Pal27 reputationPosted Aug 12, 2008, 5:22 AM EDT
Thanks for all of the answer
RP