html tag access from the code behind

P

Pierre

Hello,

I always get a nothing object when retrieving a table tag in the aspx page.
I wonder why this piece of code doesn't work : the mytable object is still
nothing.
Here is the code :

In the aspx page :

<body>
<form id="form1" runat="server">
.....
<table id="mytable">
.....
</table>
....
</body>

As you can see, the table tag has an ID attribute.
It is this tag I would like to access.

The code behind is like this :

[declaration]
Protected mytable As System.Web.UI.HtmlControls.HtmlTable

sub page_load
mytable = Page.FindControl("mytable")
mytable.visible = true
en sub

At execution, mytable is still nothing, like if the tag wasn't found.
I do not understand what I miss. The result is the same when adding
runat="serveur" in the mytable tag.

I can't see what is wrong...

Thanks a lot.

Pierre.
 
G

Guest

Dear Pierre,
Since there have a server control for creating table, it had better use the
table control instead of HTML control by doing that, it will give the control
more controllable and the code will be more clear

Hope this help you!
Regards
Joe Tsui
 
P

Pierre

It's not precisely what I expected...

Does it show what is wrong in the code below ?

Regards,

Pierre.


Joe said:
Dear Pierre,
Since there have a server control for creating table, it had better use
the
table control instead of HTML control by doing that, it will give the
control
more controllable and the code will be more clear

Hope this help you!
Regards
Joe Tsui

Pierre said:
Hello,

I always get a nothing object when retrieving a table tag in the aspx
page.
I wonder why this piece of code doesn't work : the mytable object is
still
nothing.
Here is the code :

In the aspx page :

<body>
<form id="form1" runat="server">
.....
<table id="mytable">
.....
</table>
....
</body>

As you can see, the table tag has an ID attribute.
It is this tag I would like to access.

The code behind is like this :

[declaration]
Protected mytable As System.Web.UI.HtmlControls.HtmlTable

sub page_load
mytable = Page.FindControl("mytable")
mytable.visible = true
en sub

At execution, mytable is still nothing, like if the tag wasn't found.
I do not understand what I miss. The result is the same when adding
runat="serveur" in the mytable tag.

I can't see what is wrong...

Thanks a lot.

Pierre.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top