Method 1:
. AspxCode
<Form ID = "form1" method = "Post" runat = "server">
<Font face = "">
<Asp: textbox id = "textbox1" style = "Z-INDEX: 101; left: 256px; position: absolute; top: pixel"
Runat = "server"> </ASP: textbox>
<Asp: button id = "button1" style = "Z-INDEX: 104; left: 256px; position: absolute; top: 144px" runat = "server"
TEXT = "set"> </ASP: button>
<Asp: Label id = "label2" style = "Z-INDEX: 103; left: 256px; position: absolute; top: 80px "runat =" server "> dynamically set the textbox style </ASP: Label>
<Asp: Label id = "label1" style = "Z-INDEX: 102; left: 256px; position: absolute; top: 184px" runat = "server"> </ASP: label> </font>
</Form>
. Aspx. CS code
Private void button#click (Object sender, system. eventargs E)
{// Set the style
Textbox1.style. Add ("width", textbox1.text. tostring ());
Label1.text = "width" + textbox1.style ["width"]. tostring ();
}
Method 2:
. Aspx code
<Form ID = "form1" method = "Post" runat = "server">
<Asp: Label id = "label1" style = "Z-INDEX: 101; left: pixel PX; position: absolute; top: 48px "runat =" server "> dynamically set the style of the server control </ASP: Label>
<Asp: button id = "button1" style = "Z-INDEX: 103; left: pixel PX; position: absolute; top: pixel" runat = "server"
TEXT = "set"> </ASP: button>
<Asp: textbox id = "textbox1" style = "Z-INDEX: 102; left: pixel PX; position: absolute; top: 80px" runat = "server"> </ASP: textbox>
</Form>
. Aspx. CS code
private void button#click (Object sender, system. eventargs e)
{// set the style
Style = new style ();
style. bordercolor = color. black;
style. borderstyle = borderstyle. inset;
style. borderwidth = new Unit (1);
textbox1.applystyle (style);
}