By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,187 Members | 1,062 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,187 IT Pros & Developers. It's quick & easy.

Adding <div> tag programatically

P: n/a
Hi All,

I would like to add the <div> tag programatically from the code-behind
of my aspx file. Basically, I would like to a table to this <div>.
There are a number of tables which are created dynamically in the
code-behind. Each table should go to its own <div> tag.
The reason that I can't have the <div> tags in aspx is that the number
of the tables is unknown until runtime and each table should go into
its own <div> tag.
How is this possible?
Thanks.
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
using System.Web.UI.HtmlControls;

HtmlGenericControl div1 = new HtmlGenericControl("div");
div1.ID = "div1";
// add whatever attributes you need, eg make it scrollable:
div1.Attributes["style"] = "overflow: auto; width: 400px; height: 150px;";

// initialize your table
HtmlTable table1 = new HtmlTable();
table1.ID = "table1";
//....

// add the table to the div:
div1.Controls.Add(table1);

// add it to some PlaceHolder:
placeHolder1.Controls.Add(div1);

Greetings
Martin
"DJ Dev" <ri*********@icn.siemens.com> wrote in message
news:11*************************@posting.google.co m...
Hi All,

I would like to add the <div> tag programatically from the code-behind
of my aspx file. Basically, I would like to a table to this <div>.
There are a number of tables which are created dynamically in the
code-behind. Each table should go to its own <div> tag.
The reason that I can't have the <div> tags in aspx is that the number
of the tables is unknown until runtime and each table should go into
its own <div> tag.
How is this possible?
Thanks.

Nov 18 '05 #2

P: n/a
Use the ASP.Net Panel control, which renders a div on the client.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"DJ Dev" <ri*********@icn.siemens.com> wrote in message
news:11*************************@posting.google.co m...
Hi All,

I would like to add the <div> tag programatically from the code-behind
of my aspx file. Basically, I would like to a table to this <div>.
There are a number of tables which are created dynamically in the
code-behind. Each table should go to its own <div> tag.
The reason that I can't have the <div> tags in aspx is that the number
of the tables is unknown until runtime and each table should go into
its own <div> tag.
How is this possible?
Thanks.

Nov 18 '05 #3

P: n/a
Use the ASP.Net Panel control, which renders a div on the client.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"DJ Dev" <ri*********@icn.siemens.com> wrote in message
news:11*************************@posting.google.co m...
Hi All,

I would like to add the <div> tag programatically from the code-behind
of my aspx file. Basically, I would like to a table to this <div>.
There are a number of tables which are created dynamically in the
code-behind. Each table should go to its own <div> tag.
The reason that I can't have the <div> tags in aspx is that the number
of the tables is unknown until runtime and each table should go into
its own <div> tag.
How is this possible?
Thanks.

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.