Reputation: 15607
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?
Upvotes: 3
Views: 15039
Reputation: 3328
You can add in this way also :-
progressBar.Style.Add(HtmlTextWriterStyle.Width, "200px");
Upvotes: 0
Reputation: 630389
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";
Upvotes: 9