Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. checkbox problem

checkbox problem

Scheduled Pinned Locked Moved ASP.NET
helpquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eyeseetee
    wrote on last edited by
    #1

    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

    P B B 3 Replies Last reply
    0
    • E eyeseetee

      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

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      Use the code tags when posting code. It makes it easier to read. Is your checkbox's default value false 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

      1 Reply Last reply
      0
      • E eyeseetee

        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

        B Offline
        B Offline
        bokuceres
        wrote on last edited by
        #3

        Hi, have you add ?

        if (!ispostback)
        {
        }

        1 Reply Last reply
        0
        • E eyeseetee

          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

          B Offline
          B Offline
          bhanu12345
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups