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. How to hide label ?

How to hide label ?

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelptutorialquestion
6 Posts 3 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.
  • K Offline
    K Offline
    kyi kyi
    wrote on last edited by
    #1

    Hi i created customed login page. it has one label to show error message like "incorrect login". it also has validation summary for username and password. if user fill incorrect login name and password, the label will show "incorrect login". if login name text box or password text box miss to fill, it will show only validation summary. when i fill wrong data, it shows error msg. and i ommit one textbox or both(username and password), it show both of validation summary and error msg(label). i dont' want to show error msg if the page is not valid. i also checked "if(page.Isvalid)". but error msg(label )remain the same. any suggestion pls? i m using asp.net 2.0 and VS2005. thanks in advance!

    A E 2 Replies Last reply
    0
    • K kyi kyi

      Hi i created customed login page. it has one label to show error message like "incorrect login". it also has validation summary for username and password. if user fill incorrect login name and password, the label will show "incorrect login". if login name text box or password text box miss to fill, it will show only validation summary. when i fill wrong data, it shows error msg. and i ommit one textbox or both(username and password), it show both of validation summary and error msg(label). i dont' want to show error msg if the page is not valid. i also checked "if(page.Isvalid)". but error msg(label )remain the same. any suggestion pls? i m using asp.net 2.0 and VS2005. thanks in advance!

      A Offline
      A Offline
      Anish Gopi
      wrote on last edited by
      #2

      On Client side Labels are render as "SPAN" tag. So write a javascript method which set an empty string to the control on your button click

      function clearControls()
      {
      var ctrl = document.getElementById('labelname');
      if (ctrl != null)
      {
      ctrl.innerHTML = '';
      }
      }

      Call the above method on button click

      It would be great if you turn off the ViewStatate for this particular labe1.

      K 1 Reply Last reply
      0
      • K kyi kyi

        Hi i created customed login page. it has one label to show error message like "incorrect login". it also has validation summary for username and password. if user fill incorrect login name and password, the label will show "incorrect login". if login name text box or password text box miss to fill, it will show only validation summary. when i fill wrong data, it shows error msg. and i ommit one textbox or both(username and password), it show both of validation summary and error msg(label). i dont' want to show error msg if the page is not valid. i also checked "if(page.Isvalid)". but error msg(label )remain the same. any suggestion pls? i m using asp.net 2.0 and VS2005. thanks in advance!

        E Offline
        E Offline
        eyeseetee
        wrote on last edited by
        #3

        So you want to only show the error message when the login is not in the database. If they dont enter anything and click a button you want a required field validator to fire, is that correct? Just add a required field validator to the control and that will check if the field contains a value.

        K 1 Reply Last reply
        0
        • E eyeseetee

          So you want to only show the error message when the login is not in the database. If they dont enter anything and click a button you want a required field validator to fire, is that correct? Just add a required field validator to the control and that will check if the field contains a value.

          K Offline
          K Offline
          kyi kyi
          wrote on last edited by
          #4

          thanks for your answer. yes. i alredy put required field validator. if page is not valid, validation summary show error msg. if page is valid and it is incorrrect login, lable will show "incorrect login". after displaying label, it's not disappear.my problem is like that. thanks again.

          K 1 Reply Last reply
          0
          • A Anish Gopi

            On Client side Labels are render as "SPAN" tag. So write a javascript method which set an empty string to the control on your button click

            function clearControls()
            {
            var ctrl = document.getElementById('labelname');
            if (ctrl != null)
            {
            ctrl.innerHTML = '';
            }
            }

            Call the above method on button click

            It would be great if you turn off the ViewStatate for this particular labe1.

            K Offline
            K Offline
            kyi kyi
            wrote on last edited by
            #5

            thanks for your answer. i will try.

            1 Reply Last reply
            0
            • K kyi kyi

              thanks for your answer. yes. i alredy put required field validator. if page is not valid, validation summary show error msg. if page is valid and it is incorrrect login, lable will show "incorrect login". after displaying label, it's not disappear.my problem is like that. thanks again.

              K Offline
              K Offline
              kyi kyi
              wrote on last edited by
              #6

              Hi.. now i can fix this problem. in required field validator, enabledclientscript to false. thanks.

              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