Display label information
<% @ Page language = "vb" %>
<Script runat = "server">
Sub page_load (obj as object, e as eventargs)
Lblmessage. text = "this is my first exercise! "
End sub
</Script>
<Html> <body>
<Asp Tutorial: label id = "lblmessage" runat = "server"/>
</Body>
The tag loads the event listening text on the page.
<% @ Page language = "vb" %>
<Script runat = "server">
Sub page_load (obj as object, e as eventargs)
Lblmessage. text = "this is my first exercise! "
End sub
</Script>
<Html> <body>
<Asp: label id = "lblmessage" runat = "server"/>
</Body>
Add css tutorial to label
<% @ Page language = "c #" %>
<! Doctype html public "-// w3c // dtd xhtml 1.1 // en" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> untitled page </title>
<Style rel = "stylesheet" type = "text/css">
Body
{
Font-family: verdana, arial, sans-serif;
Font-size: small;
}
. Heading1
{
Font-weight: bold;
Font-size: large;
Color: lime;
}
. Heading2
{
Font-weight: bold;
Font-size: medium;
Font-style: italic;
Color: # c0ba72;
}
. Blocktext
{
Padding: 10px;
Background-color: # ffffd9;
Border-style: solid;
Border-width: thin;
}
</Style>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>
<Asp: label cssclass = "heading1" id = "label1" runat = "server" text = "this label uses heading1"> </asp: label>
<Br/>
This is sample unformatted text. <br/>
& Nbsp; <br/>
<Asp: label cssclass = "heading2" id = "label2" runat = "server" text = "this label uses heading2"> </asp: label>
<Br/>
Here's more unformatted text. <br/>
<Br/>
& Nbsp; <div class = "blocktext" id = "div1" runat = "server">
This control uses the blocktext style. this control uses the blocktext style. this
Control uses the blocktext style. this control uses the blocktext style.
</Div>
</Div>
</Form>
</Body>
</Html>
Font increase
<% @ Page language = "c #" autoeventwireup = "true" codefile = "default. aspx. cs" inherits = "_ default" %>
<! Doctype html public "-// w3c // dtd xhtml 1.1 // en" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head id = "head1" runat = "server">
<Title> asp.net tutorial server controls-basics </title>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>
<H1> asp.net server controls <H2> basics <Asp: label id = "lbltime" runat = "server" oninit = "lbltime_init"> </asp: label>
</Div>
</Form>
</Body>
</Html>
File: default. aspx. cs
Using system;
Using system. data;
Using system. configuration;
Using system. web;
Using system. web. security;
Using system. web. ui;
Using system. web. ui. webcontrols;
Using system. web. ui. webcontrols. webparts;
Using system.web.ui.html controls;
Public partial class _ default: system. web. ui. page
{
Protected void lbltime_init (object sender, eventargs e)
{
Lbltime. font. name = "verdana ";
Lbltime. font. size = 20;
Lbltime. font. underline = true;
Lbltime. font. bold = true;
Lbltime. font. italic = true;
Lbltime. font. overline = true;
Lbltime. font. strikeout = true;
Lbltime. text = datetime. now. tostring () + ". font name:" + lbltime. font. name;
}
}
Set the lebel Running code
Page language = 'vb'
<% @ Page language = "vb" %>
<Script runat = "server">
Sub page_load (obj as object, e as eventargs)
Lblmessage. text = "welcome to asp.net! "
End sub
</Script>
<Html>
<Body>
<Asp: label id = "lblmessage" runat = "server"/>
</Body>
</Html>