PC Review


Reply
Thread Tools Rate Thread

Add div to asp.net page

 
 
shapper
Guest
Posts: n/a
 
      25th May 2007
Hello,

I want to add a div tag with a few properties (class, id, ...) to a
page. I would like to build the following block:

<div id="myid" class="myclass">

<Asp:TextBox> ...

</div>

I don't want to add the div using Asp:Panel.

I know I can use literal. But is there another way to define the div
and its properties before adding it to the page without using a
string?

What should be the best way to do this?

Thanks,

Miguel

 
Reply With Quote
 
 
 
 
Michael Nemtsev
Guest
Posts: n/a
 
      25th May 2007
Hello Shapper,

use HtmlGenericControl like this

Control control = this.FindControl("body");
HtmlControl divControl = new HtmlGenericControl("div");
divControl.Attributes.Add("id","myid");
divControl.Attributes.Add("class","myclass");
control.Controls.Add(divControl);




---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

S> Hello,
S>
S> I want to add a div tag with a few properties (class, id, ...) to a
S> page. I would like to build the following block:
S>
S> <div id="myid" class="myclass">
S>
S> <Asp:TextBox> ...
S>
S> </div>
S>
S> I don't want to add the div using Asp:Panel.
S>
S> I know I can use literal. But is there another way to define the div
S> and its properties before adding it to the page without using a
S> string?
S>
S> What should be the best way to do this?
S>
S> Thanks,
S>
S> Miguel
S>


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
page numbers in Word 2007 - skipping page number on first page John Goche Microsoft Word New Users 1 13th Nov 2009 04:04 PM
Inserting a page in Page Layout View or Page Break Preview tanner.robin@gmail.com Microsoft Excel Discussion 1 6th Jun 2008 02:52 PM
Setting the Page Title using local resources for a content page in a master page Laith Zraikat Microsoft ASP .NET 3 6th Jul 2006 02:23 AM
single page or page range printing for multi page emails in outlo. =?Utf-8?B?RGVsIFBhdWxzb24=?= Microsoft Outlook Discussion 1 26th Apr 2005 07:41 PM
Report footer on separate page; optionally hide it, reduce total page count by 1, and don't print last (blank) page L Mehl Microsoft Access Reports 2 18th Sep 2003 01:49 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:36 PM.