473,503 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding <div> tag programatically

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
3 30419
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
3376
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to...
1
2486
by: Philo | last post by:
How do I select all <div> tags except those which contain a <table> tag somewhere within them? Example XML: <********************** sample input ***********************> <txtSectionBody>...
4
3542
by: Akbar | last post by:
All, I'm currently using an alt attribute in a div tag to store "keywords" for a function that will show or hide certain div's based on a given keyword. Is there a better (standard) place to put...
8
14448
by: Daniel Hansen | last post by:
I know this must seem totally basic and stupid, but I cannot find any reference that describes how to control the spacing between <p>...</p> and <div>...</div> blocks. When I implement these on a...
1
1325
by: Steve Klett | last post by:
Hi- I was just looking at te source for a site that I really liked and I noticed they are using DIV tags where I assumed that would be using a mess of nested tables. Now, this looks like a much...
1
402
by: DJ Dev | last post by:
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...
4
1850
by: Alan Silver | last post by:
Hello, I would like to know if it is possible to use a panel, but prevent it from adding a <div> tag to the HTML. The reason I want to do this is that I am using a panel to enable me to...
3
3791
by: Josef K. | last post by:
Asp.net generates the following html when producing RadioButton lists: <td><input id="RadioButtonList_3" type="radio" name="MyRadioButtonList" value="644"...
4
1492
by: Jeff | last post by:
Hello, I'm fairly new to asp.net programming (I come from a C++ background) and am still finding some things very confusing. I wondered if anyone could help me with the following issue. I...
8
10015
prino
by: prino | last post by:
Hi all, I've written code (in REXX) that takes files in legacy languages (PL/I, COBOL, z/OS assembler, etc) and converts them into HTML in a format similar to what's displayed in the z/OS ISPF...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7348
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7006
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7467
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5592
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5021
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
397
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.