Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to add a <Div> tag trough coding in asp .net 1

Status
Not open for further replies.

ganjafarmerIT

Programmer
Jun 29, 2004
30
NL
Hi people, I'm having trouble figuring out how to add a <div> element trough coding to my costumcontrol.
My control consist of three child controls. And I need one of them to be in a <div>.

thanks in advance
 
If you mean adding a <DIV> tag to the control itself, simply put it there when you create the .aspx part of the page. You just use HTML there as you normally would.

If you mean you want to add the control inside of a <DIV> tag on a different page simply put the call to the control where you want it.

For example:
<%@ Register TagPrefix="customcontrol" TagName="custom" Src="/CustomControl.ascx"%>

<div align="center">
<customcontrol:custom id="ccCustom" runat="server">
</div>

HTH

Eva
 
thanks for your reply, I think there is a little misunderstanding. let me explain:

What I wan't to accomplish is this.

My costum control consist of a textbox, chekbox and a calendar control.

dim textb as textbox
dim chkbox as checkbox
dim calendar as calendar

What I want is to accomplish that in the costum control itself, part of it(the calendar control) will be in a div.

I'm not trying to accomplish the following:

<div align="center">
<customcontrol:custom id="ccCustom" runat="server">
</div>

because that will put the final control in a div.
after it has been dragged to the form.
 
I do believe that you're looking for something like this...

Code:
WebControl div = new WebControl(HtmlTextWriterTag.Div);
base.Controls.Add(div);

/* 
Configure properties after the control has
been added to the base to preserve viewstate
*/
div.Attributes.Add("align", "center");

Hope that helps

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
thanks for your reply m8, gonna try this as soon as I finish my meal;) I'll let you know if it worked, thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top