Below is the sample (c#) code for create a div tag in asp.net. The following code will give out put like this...
protected void Page_Load(object sender, EventArgs e) { System.Web.UI.HtmlControls.HtmlGenericControl createDiv = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV"); createDiv.ID = "createDiv"; createDiv.Style.Add(HtmlTextWriterStyle.BackgroundColor, "Yellow"); createDiv.Style.Add(HtmlTextWriterStyle.Color, "Red"); createDiv.Style.Add(HtmlTextWriterStyle.Height, "100px"); createDiv.Style.Add(HtmlTextWriterStyle.Width, "400px"); createDiv.InnerHtml = " I'm a div, from code behind "; this.Controls.Add(createDiv); }
1 comments:
my self Ankish Saini from India
Thanks a lot its working fine.
Can u help me, i want to add a div on every button click, means a unique div.
please help me.....thanks in advance.
Post a Comment
Share your thoughts here...