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. Display / visible method in Javascript

Display / visible method in Javascript

Scheduled Pinned Locked Moved ASP.NET
javascript
5 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.
  • S Offline
    S Offline
    sandeep kumar pundhir
    wrote on last edited by
    #1

    Hi, I m using javascript to make a textbox visible, which is set to style=display:none at the page load.But when i click the button (On which javascript is method is called), the textbox doesnot makes it visible. I m doing protected void Page_Load(object sender, EventArgs e) { string str = "function radio()" + "{" + "if(document.getElementById('radio1').Checked!=true)" + "{" + "document.getElementById('" + TextBox1.ClientID + "').visible;" + "alert('sandeep');" + "}" + "}"; this.RegisterClientScriptBlock("clientScript", str); Button1.Attributes.Add("onClick", "radio()"); } Where i am going wrong... Thanx

    M I 2 Replies Last reply
    0
    • S sandeep kumar pundhir

      Hi, I m using javascript to make a textbox visible, which is set to style=display:none at the page load.But when i click the button (On which javascript is method is called), the textbox doesnot makes it visible. I m doing protected void Page_Load(object sender, EventArgs e) { string str = "function radio()" + "{" + "if(document.getElementById('radio1').Checked!=true)" + "{" + "document.getElementById('" + TextBox1.ClientID + "').visible;" + "alert('sandeep');" + "}" + "}"; this.RegisterClientScriptBlock("clientScript", str); Button1.Attributes.Add("onClick", "radio()"); } Where i am going wrong... Thanx

      M Offline
      M Offline
      Michael Sync
      wrote on last edited by
      #2

      sandeep kumar pundhir wrote:

      "document.getElementById('" + TextBox1.ClientID + "').visible;" +

      document.getElementById('" + TextBox1.ClientID + "').style.display = 'block';

      Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

      S 1 Reply Last reply
      0
      • M Michael Sync

        sandeep kumar pundhir wrote:

        "document.getElementById('" + TextBox1.ClientID + "').visible;" +

        document.getElementById('" + TextBox1.ClientID + "').style.display = 'block';

        Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

        S Offline
        S Offline
        sandeep kumar pundhir
        wrote on last edited by
        #3

        Thanx for ur reply. But now wat is hapening.... The textbox1 becomes visible for a second after clicking the button, it again disappears

        M 1 Reply Last reply
        0
        • S sandeep kumar pundhir

          Hi, I m using javascript to make a textbox visible, which is set to style=display:none at the page load.But when i click the button (On which javascript is method is called), the textbox doesnot makes it visible. I m doing protected void Page_Load(object sender, EventArgs e) { string str = "function radio()" + "{" + "if(document.getElementById('radio1').Checked!=true)" + "{" + "document.getElementById('" + TextBox1.ClientID + "').visible;" + "alert('sandeep');" + "}" + "}"; this.RegisterClientScriptBlock("clientScript", str); Button1.Attributes.Add("onClick", "radio()"); } Where i am going wrong... Thanx

          I Offline
          I Offline
          Imran Khan Pathan
          wrote on last edited by
          #4

          "if(document.getElementById('radio1').Checked!=true)" + "{" + "document.getElementById('" + TextBox1.ClientID + "').style.display=block;" + "}" + "else"+ "{"+ "document.getElementById('" + TextBox1.ClientID + "').style.display=none;" + "}"+ "return false;" Best Regard Pathan -- modified at 1:00 Friday 31st August, 2007

          ---------------------------------------------------

          1 Reply Last reply
          0
          • S sandeep kumar pundhir

            Thanx for ur reply. But now wat is hapening.... The textbox1 becomes visible for a second after clicking the button, it again disappears

            M Offline
            M Offline
            Michael Sync
            wrote on last edited by
            #5

            sandeep kumar pundhir wrote:

            The textbox1 becomes visible for a second after clicking the button, it again disappears

            Oh. Yeah. It will happen like that.. So, you have to cache the status (whether this is currently visible or not.) then, you have to set it back on Page Load.

            Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

            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