tags:

views:

36

answers:

3

In the aspx page I have div with id="progressBar" and runat="server".I need to add width of the div from code behind in C#.

Can anyone help me how to do this?

+3  A: 

You can set it's Style property, like this:

progressBar.Style[HtmlTextWriterStyle.Width] = "200px";
//or just use a string:
progressBar.Style["width"] = "200px";

Alternatively, you can give it a CSS class, define this in your CSS:

.progress { width: 200px; }

And assign that class in your markup like this:

<div id="progressBar" runat="server" class="progress">

Or in your code-behind:

progressBar.Attributes["class"] = "progress";
Nick Craver
A: 

You can add in this way also :-

progressBar.Style.Add(HtmlTextWriterStyle.Width, "200px");

Karan
A: 

progressBar.Style.Add("width", "300px");