checkbox problem
-
Hi I have a checkbox which is displayed on a page The checkbox is ticked when the page loads i want the following to run: if (CheckBox_room_reviewed.Checked == true) { lbl_username.Visible = true; } else if (CheckBox_room_reviewed.Checked == false) { lbl_username.Visible = false; } but it doesnt show the lblusername. If i clcik on a radiobutton which is on my page and postback then it shows how do i get it to show when the page first loads ive tried page_init and it doesnt work in there either thanks in advance
-
Hi I have a checkbox which is displayed on a page The checkbox is ticked when the page loads i want the following to run: if (CheckBox_room_reviewed.Checked == true) { lbl_username.Visible = true; } else if (CheckBox_room_reviewed.Checked == false) { lbl_username.Visible = false; } but it doesnt show the lblusername. If i clcik on a radiobutton which is on my page and postback then it shows how do i get it to show when the page first loads ive tried page_init and it doesnt work in there either thanks in advance
Use the
code
tags when posting code. It makes it easier to read. Is your checkbox's default valuefalse
when you first load the page? Also, if-else if is not necessary for what you are doing. Try:lbl_username.Visible=CheckBox_room_reviewed.Checked
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
-
Hi I have a checkbox which is displayed on a page The checkbox is ticked when the page loads i want the following to run: if (CheckBox_room_reviewed.Checked == true) { lbl_username.Visible = true; } else if (CheckBox_room_reviewed.Checked == false) { lbl_username.Visible = false; } but it doesnt show the lblusername. If i clcik on a radiobutton which is on my page and postback then it shows how do i get it to show when the page first loads ive tried page_init and it doesnt work in there either thanks in advance
-
Hi I have a checkbox which is displayed on a page The checkbox is ticked when the page loads i want the following to run: if (CheckBox_room_reviewed.Checked == true) { lbl_username.Visible = true; } else if (CheckBox_room_reviewed.Checked == false) { lbl_username.Visible = false; } but it doesnt show the lblusername. If i clcik on a radiobutton which is on my page and postback then it shows how do i get it to show when the page first loads ive tried page_init and it doesnt work in there either thanks in advance
Hi, I think you are writing the code like this if (!IsPostBack) { if (CheckBox1.Checked == true) { TextBox3.Visible = true; } else if (CheckBox1.Checked == false) { TextBox3.Visible = false; } } remove the !IsPostBack condition and try then it will work. Bhanu