Asp.net server controls

Source: Internet
Author: User

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);
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.