VisualStudio doesn't create attribute in codebehind for <asp:tablecell>

  • Thread starter Thread starter Gürkan Demirci
  • Start date Start date
G

Gürkan Demirci

Hi,

i am using the VisualStudio FormDesigner to create an asp:table.
I want to populate an asp:tablecell with different controls at runtime.
In the codebehind file, there is an attribute for the asp:table. I can use
this to
access the tablerow and tablecell objects. It would be more convenient to
access a tablecell through
a class-attribute. Why is VisualStudio not creating an attribute for
tablerow or tablecell ?

regards,

guerkan
 
Do you mean the protected member variable right? The behaviour you're
looking for is in the HTML Table (look in the Toolbox for HTML controls not
Web Forms tabs), creating such a table will create the corresponding HTML
markup, you can then right click on the table itself or any cell and select
"Run As Server Control", this will cause VS.NET to add a runat='server'
attribute to the corresponding markup and create a matching member variable
in your codebehind file for the table or cell.

Does this help?

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Read my weblog:
Followers of the IHttpHandler
http://clariusconsulting.net/vga
 
Programing HTML elements in code-behind

To gain access to any element in code-behind, or server side script, put a runat=server attribute into the definition element. By default, the asp:TableCell is not provided with one. You also need to add an id, e.g. ID="C1".

In your code behind file, you cvan now ty C1. - and get intellisense on what you can do. In the case of adding different controls at run time, simply reference the controls. i.e.

C1.Controls.Add(...your control...);

You need to be careful about what you expect from view state when using dynamic (asp:) controls

It is also possible to use a runat=server on standard HTML controls as well for programming in the code behind file.
 

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

Back
Top