Textbox Visibility

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mathewgk80
    New Member
    • Sep 2007
    • 103

    Textbox Visibility

    Hi all,

    I would like to know whether i can set the textbox visible(which is already invisible) using javascript.

    I am using asp.net and c#.net.

    Please help me.

    regards,
    Mathew
  • iam_clint
    Recognized Expert Top Contributor
    • Jul 2006
    • 1207

    #2
    yeah
    Code:
    document.getElementById("id of the text box").style.visibility = "visible";
    or if your using display: none; then
    Code:
    document.getElementById("id of the text box").style.display= "block";

    Comment

    • kunal pawar
      Contributor
      • Oct 2007
      • 297

      #3
      You can hide any control using Style property

      For Hide :
      [CODE=javascript]document.getEle mentById('contr ol Id').style.disp lay = 'hidden';[/CODE]

      For Visible

      [CODE=javascript]document.getEle mentById('contr ol Id').style.disp lay = 'none';[/CODE]
      Last edited by acoder; Oct 24 '07, 08:27 AM. Reason: Added code tags

      Comment

      • Ferris
        New Member
        • Oct 2007
        • 101

        #4
        Originally posted by iam_clint
        yeah
        Code:
        document.getElementById("id of the text box").style.visibility = "visible";
        or if your using display: none; then
        Code:
        document.getElementById("id of the text box").style.display= "block";

        I agree with this version.

        by the way,if you use style.visibilit y ,the text box will remain in the place where it was,but you can't see it.and if you use style.display,t he text box will be removed from the place (not from the web page.)

        hope it helps.

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Originally posted by kunal pawar
          You can hide any control using Style property
          For Hide :
          [CODE=javascript]document.getEle mentById('contr ol Id').style.disp lay = 'hidden';[/CODE]
          For Visible
          [CODE=javascript]document.getEle mentById('contr ol Id').style.disp lay = 'none';[/CODE]
          You've got the style.display and style.visibilit y properties mixed up. 'hidden' and 'visible' would be used with style.visibilit y (it should be 'none' and 'block' if you're using style.display).

          In your code, the first line won't work. The second will actually hide the element.

          Comment

          • kunal pawar
            Contributor
            • Oct 2007
            • 297

            #6
            for Hide control

            document.getEle mentByID('Contr ol Id').style.disp lay="none";

            For make visible
            document.getEle mentByID('Contr ol Id').style.disp lay="";

            Comment

            • iam_clint
              Recognized Expert Top Contributor
              • Jul 2006
              • 1207

              #7
              your javascript would fail
              This code won't work
              Code:
              document.getElementByID('Control Id').style.display="";
              This code will work
              Code:
              document.getElementById('Control Id').style.display="";


              I would use a property here myself something such as inline or block..
              Code:
              document.getElementById('Control Id').style.display="inline";

              Comment

              Working...