<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:Verdana; panose-1:2 11 6 4 3 5 4 4 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:536871559 0 0 0 415 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->
ASP.NET - Web 服务器控件
Web 服务器控件是服务器可理解的特殊 ASP.NET 标签。
类似 HTML 服务器控件,Web 服务器控件也在服务器上创建,它们同样需要 runat="server" 属性以使其生效。不过,Web 服务器控件没有必要映射任何已存在的 HTML 元素,它们代表更复杂的元素。
创建 Web 服务器控件的语法是:
<asp:control_name id="some_id" runat="server" />
在下面的例子中,我们在 .aspx 文件中的声明了一个 Button 服务器控件。然后我们为 Click 事件创建了一个事件句柄,它可修改按钮上的文本:
<script runat="server">
Sub submit(Source As Object, e As EventArgs)
button1.Text="You clicked me!"
End Sub
</script>
<html>
<body>
<form runat="server">
<asp:Button id="button1" Text="Click me!" runat="server" OnClick="submit"/>
</form>
</body>
</html>
ASP.NET - Validation 服务器控件
Validation 服务器控件用于验证用户输入。如果用户输入没有通过验证,将给用户显示一条错误消息。
每种 validation 控件执行一种特定的验证类型(比如验证某个具体的值或者某个范围的值)。
默认地,当点击 Button, ImageButton 或 LinkButton 时,页面验证才会被执行。您可通过把 CausesValidation 属性设置为 false,来阻止某个按钮控件被点击时进行验证。
创建 Validation 服务器控件的语法是:
<asp:control_name id="some_id" runat="server" />
在下面的例子中,我们在 .aspx 文件中声明了一个 TextBox 控件,一个 Button 控件,以及一个 RangeValidator 控件。如果验证失败,文本 "The value must be from 1 to 100!" 将显示在 RangeValidator 控件中:
<html>
<body>
<form runat="server">
<p>Enter a number from 1 to 100:
<asp:TextBox id="tbox1" runat="server" />
<br /><br />
<asp:Button Text="Submit" runat="server" />
</p>
<p>
<asp:RangeValidator
ControlToValidate="tbox1"
MinimumValue="1"
MaximumValue="100"
Type="Integer"
Text="The value must be from 1 to 100!"
runat="server" />
</p>
</form>
</body>
</html>