How to set CSS style value from code-behind?
I have developed my aspx page and I need that page width should be adjusted as per the requirement, i read regarding this issue in some blogs that this is possible through the code behind and i also read that this will be edited with the help of <DIV /> tag and then we need to add an ID value to it, but don't know how to implement it in real life.
Thanks
Re: How to set CSS style value from code-behind?
I will provide you the C# code that will help you much more easier to setup your problem from the code-behind.
Code:
myDiv.attributes.Add("Style", "width:1000px;margin:0px auto")
This i have used as an simple outline to implement using the CSS style sheet, i am not providing you my code this is because that code would be different from yours but this will give you the better idea to do so.
Re: How to set CSS style value from code-behind?
Yes you will require to use <DIV /> and also need to Use Style collection:
myDiv.Style["width"]="200px";
and if we are concerning about the <DIV /> then you need to replace the <div> with an <asp : Panel>. and It will help to produce the same html output but will give you better choice of server-side properties.