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. access asp control in my user control via javascript

access asp control in my user control via javascript

Scheduled Pinned Locked Moved ASP.NET
csharpjavascriptasp-netquestion
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.
  • B Offline
    B Offline
    benams
    wrote on last edited by
    #1

    hi, I have an asp.net label () in my user control(ascx file). I want to change its bg color and visibility via javascript function when the user clicks on it. I try to do somethimg like this: function Change() { document.getElementById("<%=lbl1.ClientID%>").backgroundColor = "red"; } it doesnt work. anybogy has any idea?

    K N B 3 Replies Last reply
    0
    • B benams

      hi, I have an asp.net label () in my user control(ascx file). I want to change its bg color and visibility via javascript function when the user clicks on it. I try to do somethimg like this: function Change() { document.getElementById("<%=lbl1.ClientID%>").backgroundColor = "red"; } it doesnt work. anybogy has any idea?

      K Offline
      K Offline
      karlodegrano
      wrote on last edited by
      #2

      U have to use the Control UniqueID of the label you want to change color. lbl1.ClientID wont work.

      K 1 Reply Last reply
      0
      • B benams

        hi, I have an asp.net label () in my user control(ascx file). I want to change its bg color and visibility via javascript function when the user clicks on it. I try to do somethimg like this: function Change() { document.getElementById("<%=lbl1.ClientID%>").backgroundColor = "red"; } it doesnt work. anybogy has any idea?

        N Offline
        N Offline
        needtractor
        wrote on last edited by
        #3

        try this document.getElementById("<%=lbl1.ClientID%>").style.backgroundColor = "red";

        1 Reply Last reply
        0
        • K karlodegrano

          U have to use the Control UniqueID of the label you want to change color. lbl1.ClientID wont work.

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

          This link wil further explain it to you. http://forums.asp.net/t/443188.aspx[^]

          1 Reply Last reply
          0
          • B benams

            hi, I have an asp.net label () in my user control(ascx file). I want to change its bg color and visibility via javascript function when the user clicks on it. I try to do somethimg like this: function Change() { document.getElementById("<%=lbl1.ClientID%>").backgroundColor = "red"; } it doesnt work. anybogy has any idea?

            B Offline
            B Offline
            benams
            wrote on last edited by
            #5

            thank for the answers , but it is not working. in addition I have a new strange problem: when I try to run this line with VS2008 (in other computer) , I get some compilation errors, anybody knows what is it?

            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