applyrequiredfield.aspx
来自「asp.net专家200问(含源代码解决法案」· ASPX 代码 · 共 94 行
ASPX
94 行
<%@ Page language="c#" Codebehind="ApplyRequiredField.aspx.cs" AutoEventWireup="false" Inherits="ApplyRequiredFielValidator.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<h3><font face="宋体">简单的 RequiredField 验证程序示例</font></h3>
<br>
<form runat="server" ID="Form1">
<table bgcolor="#eeeeee" cellpadding="10">
<tr valign="top">
<td colspan="3">
<asp:Label ID="lblOutput" Text="请填写下面的必需字段" ForeColor="red" Font-Name="宋体" Font-Size="10" runat="server" /><br>
</td>
</tr>
<tr>
<td colspan="3">
<font face="宋体" size="2"><b>信用卡信息</b></font>
</td>
</tr>
<tr>
<td align="right">
<font face="宋体" size="2">卡类型:</font>
</td>
<td>
<ASP:RadioButtonList id="RadioButtonList1" RepeatLayout="Flow" runat="server">
<asp:ListItem>MasterCard</asp:ListItem>
<asp:ListItem>Visa</asp:ListItem>
</ASP:RadioButtonList>
</td>
<td align="middle" rowspan="1">
<asp:RequiredFieldValidator id="RequiredFieldValidator1" ControlToValidate="RadioButtonList1" Display="Static" InitialValue="" Width="100%" runat="server">
*
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<font face="宋体" size="2">卡号:</font>
</td>
<td>
<ASP:TextBox id="TextBox1" runat="server" />
</td>
<td>
<asp:RequiredFieldValidator id="RequiredFieldValidator2" ControlToValidate="TextBox1" Display="Static" Width="100%" runat="server">
*
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<font face="宋体" size="2">截止日期:</font>
</td>
<td>
<ASP:DropDownList id="DropDownList1" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem>01/01</asp:ListItem>
<asp:ListItem>02/01</asp:ListItem>
<asp:ListItem>03/01</asp:ListItem>
<asp:ListItem>04/01</asp:ListItem>
<asp:ListItem>05/01</asp:ListItem>
<asp:ListItem>06/01</asp:ListItem>
<asp:ListItem>07/01</asp:ListItem>
<asp:ListItem>08/01</asp:ListItem>
<asp:ListItem>09/01</asp:ListItem>
<asp:ListItem>10/01</asp:ListItem>
<asp:ListItem>11/01</asp:ListItem>
<asp:ListItem>12/01</asp:ListItem>
</ASP:DropDownList>
</td>
<td>
<asp:RequiredFieldValidator id="RequiredFieldValidator3" ControlToValidate="DropDownList1" Display="Static" InitialValue="" Width="100%" runat="server">
*
</asp:RequiredFieldValidator>
</td>
<td></td>
<tr>
<td></td>
<td>
<ASP:Button id="ValidatorBtn" text="验证" runat="server" />
</td>
<td></td>
</tr>
</table>
</form>
<P><FONT face="宋体"></FONT></P>
</body>
</HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?