Click here to Skip to main content
15,901,426 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I just want to create a div inside div using C#.net.Im using this code.
Div is Created but Div not created inside div. Please suggest me.
Wht can i do?

C#
System.Web.UI.HtmlControls.HtmlGenericControl Panel = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
        Panel.ID = "panel1";
        Panel.Style.Add(HtmlTextWriterStyle.BackgroundColor, "White");
        Panel.Style.Add(HtmlTextWriterStyle.Height, "680px");
        Panel.Style.Add(HtmlTextWriterStyle.Width, "660px");
        Panel.Style.Add(HtmlTextWriterStyle.BorderColor, "Black");
        Panel.Style.Add(HtmlTextWriterStyle.BorderStyle, "Groove");
        Panel.Style.Add(HtmlTextWriterStyle.BorderWidth, "2px");
        System.Web.UI.HtmlControls.HtmlGenericControl div = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
        div.ID = "panel12";
        div.Style.Add(HtmlTextWriterStyle.BackgroundColor, "White");
        div.Style.Add(HtmlTextWriterStyle.Height, "70px");
        div.Style.Add(HtmlTextWriterStyle.Width, "60px");
        div.Style.Add(HtmlTextWriterStyle.BorderColor, "Black");
        div.Style.Add(HtmlTextWriterStyle.BorderStyle, "Groove");
        div.Style.Add(HtmlTextWriterStyle.BorderWidth, "2px");
        this.Controls.Add(Panel);
        this.Controls.Add(div);
Posted
Updated 30-Mar-11 20:18pm
v2
Comments
m@dhu 31-Mar-11 2:18am    
Always wrap your code in pre block for better readability.


this.Controls.Add(Panel);        
Panel.Controls.Add(div);



Try This one
 
Share this answer
 
Comments
Manfred Rudolf Bihy 31-Mar-11 6:35am    
Solution was already given 4 hours ago, what are you up to? 1
Create table inside that div and in its td
you can give another div
 
Share this answer
 
v2
wouldn't it be Panel.Controls.Add(div)?
instead of this.Controls.Add(div);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900