Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi everyone, i am developing a web pages, here i have one situation , to make div tag on selection of size(height and Width) from a dropdownbox.how to i assign a value of div tag height and Width from dropdown selection,
here i am pass a value:
100 x 200, 150 x 200, 200 x 200,100 x 600,150 x 500;
how i assign a value(height/width) to span tag or div tag:
Posted
Comments
Varun Sareen 17-May-13 1:46am    
what have you tried so far.? Have you tried searching google for the same.

Always try first then if you face some problem then post it here.

Regards

Varun Sareen

Dear Friend,

I hope the below mentioned link might help you out.

About 944,000 results on how to dynamically add div asp.net

Please don't forget to mark this as your answer if it helps you out.

Thanks & Regards

Varun Sareen
 
Share this answer
 
Comments
srigates 17-May-13 1:51am    
thanks friend, :some technical fault:(have a Laugh).
Varun Sareen 17-May-13 2:05am    
your welcome dear. Please don't forget to mark this as your answer if it helps you out.
Use simple javascript to accomplish this as follows

C#
var yourdiv = document.getElementById("yourdiv");
var curr_width = yourdiv.style.width;
yourdiv.style.width = set your width as you want;
 
Share this answer
 
protected void Button1_Click(object sender, EventArgs e)
 {
     HtmlGenericControl dynDiv = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
     dynDiv.ID ="dynDivCode";
     dynDiv.Style.Add(HtmlTextWriterStyle.BackgroundColor,"#"+txt_colorpicker.Text);
     dynDiv.Style.Add(HtmlTextWriterStyle.Height,txt_ht.Text+"px");
     dynDiv.Style.Add(HtmlTextWriterStyle.Width, txt_wth.Text+"px");
     dynDiv.Style.Add(HtmlTextWriterStyle.MarginTop, "60px");
     dynDiv.Style.Add(HtmlTextWriterStyle.MarginBottom,"55px");
     dynDiv.Style.Add(HtmlTextWriterStyle.MarginLeft, "200");
     dynDiv.Style.Add(HtmlTextWriterStyle.MarginRight, "90");
     dynDiv.Style.Add(HtmlTextWriterStyle.FontFamily, "Calibri");

     dynDiv.InnerHtml =""+ txt_desc.Text+ "";
     this.Controls.Add(dynDiv);


}
 
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