Showing/Hiding Some Elements in JS

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi. I want to write a function that will show or hide a few elements on the
client-side. The elements that I'm working with are, for example, an
<asp:Label />.

Let's say I have:
<asp:Label id="SomeLB" runat="server" Text="Hi there" />

For the C# to generate my JavaScript, I know that I have to use the
ClientID, and the one line I was using looked like:
SomeLB.ClientID + ".visible=false;";

Got a JavaScript error so I tried...
SomeLB.ClientID + ".style=\"visibility:hidden;\";";

What's the right way to do this?

Alex
 
Hi Alex,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to hide a label on an aspx
page using javascript. If there is any misunderstanding, please feel free
to let me know.

you can try to use the following as script by either put it on the page or
register it with C# code.

document.getElementById("SomeLb").style.display="none";

PS: Next time please post the aspx questions in aspnet newsgroup. This
newsgroup is for ADO.NET discussion. Thank you! :-)

Kevin Yu
Microsoft Online Community Support

============================================================================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============================================================================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Alex,

As Kevin said this is not the best newsgroup for this. Beside as Kevin
stated, can you try this as well in the language newsgroup languages.C#
inspite of an ASP answer you would probably have gotten there a code behind
answer as

\\\
SomeLB.ClientID.visible = false;
///

I hope this helps,

Cor
 
Hey - Thanks for your help and actually, I posted here by accident. "ADO.NET"
and "ASP.NET" look so alike! :)

Thanks for your help anyway and happy 4th!

Alex
 
Never mind! Happy posting!

Kevin Yu
Microsoft Online Community Support

============================================================================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============================================================================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top