Hide Table with OnClick

P

Phillip Vong

Newbie here on ASP.NET

I want to hide a Table with and OnClick event. How do you do that? I'm not
showing an ID when I create a table so how do I tell it to hide it? Is
there a way to add an ID to a table? If so, how do you hide it. Please
give it to me in a format like you would for a Label (label1.visible =
False)

Thanks in advance

Phil
 
N

neilmcguigan

<script runat="server" language="C#">

protected void Button1_Click(object sender, EventArgs e)
{
table1.Visibile = false;
}

</script>

<table id="table1" runat="server"></table>
<asp:button id="Button1" runat="server" onclick="Button1_Click" />
 
A

Aemca

Phillip Vong said:
Newbie here on ASP.NET

I want to hide a Table with and OnClick event. How do you do that? I'm
not showing an ID when I create a table so how do I tell it to hide it?
Is there a way to add an ID to a table? If so, how do you hide it.
Please give it to me in a format like you would for a Label
(label1.visible = False)

If you want to do it with a server side click event go with:

<table id=table1 runat=server>

then just do:
table1.visible = false
 
R

Richard Carpenter

Anyone other novices do like I did and start with, "Sure, that should
be easy enough by just adding an ID and then an event
handl....wait...huh."

You can add an id to the table with the typical id="Table1" attribute
and even add an OnClick event handler with OnClick="Table1_Click", but
I don't see how to make the table accessible from the Table1_Click
event code. I'm guessing there is something different about dealing
with containers, maybe? I find it odd that OnClick is aparently
appropriate for a table, yet not implemented the same as other
clickable controls.

Rich
 
P

Phillip Vong

Thanks for the reply. I've already tried that and it's telling me table1 is
not defined.
 
P

Phillip Vong

I'm not talking about clicking the table. Just the button. When I give the
<table id=table1 runat=server> and I try table1.visible = false

It tells me table1 is not defined. Maybe I forgot to mention that I'm using
VS2005 in MasterPage and the table is in one of the contents.
 
R

Richard Carpenter

Doh! runat="server" fixed the problem of it not being visible in the
Table1_Click event, but now I get a "Table1_Click has not been defined"
error on the page, even though that *is* the name of the procedure I
created.

Rich
 
N

neilmcguigan

you could also hide it on the client side:

<table onclick=" this.style.display = 'none' ; ">

cheers

neil
 
P

Phillip Vong

The table is in the CONTENT and I would like to do it from the server side.
Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top