Home All Groups Group Topic Archive Search About

Showing/Hiding Some Elements in JS

Author
3 Jul 2006 7:35 PM
Alex Maghen
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

Author
4 Jul 2006 3:26 AM
Kevin Yu [MSFT]
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.)
Author
4 Jul 2006 2:24 PM
Alex Maghen
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

Show quote
"Kevin Yu [MSFT]" wrote:

> 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.)
>
>
Author
5 Jul 2006 3:31 AM
Kevin Yu [MSFT]
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.)
Author
4 Jul 2006 4:11 AM
Cor Ligthert [MVP]
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

Show quote
"Alex Maghen" <AlexMaghen@newsgroup.nospam> schreef in bericht
news:D49115DC-6CEF-4A23-A3C3-CCC724457CED@microsoft.com...
> 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

AddThis Social Bookmark Button