RequiredFieldValidator验证控件的应用
<form id="form1" runat="server">
<div>
<center>
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" style="font-size:32pt; color: White; background-color: #669900">
留言板
</td>
</tr>
<tr>
<td style="font-size: 10pt">
用户名:
</td>
<td style="width: 4px">
<asp:TextBox ID="UserNameTextBox" runat="server" Enabled="false"></asp:TextBox>
</td>
</tr>
<tr>
<td style="font-size: 10pt">
留言主题:
</td>
<td align="left">
<asp:TextBox ID="themeTextBox" runat="server" Width="233px"></asp:TextBox>
<asp:RequiredFieldValidator ID="themeRequiredFieldValidator" runat="server"
ErrorMessage="留言主题不能为空" ControlToValidate="themeTextBox">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td style="font-size: 10pt">
留言内容:
</td>
<td align="left">
<asp:TextBox ID="contentTextBox" runat="server" Height="214px" Width="233px"></asp:TextBox>
<asp:RequiredFieldValidator ID="contentRequiredFieldValidator" runat="server"
ErrorMessage="留言内容不能为空" ControlToValidate="contentTextBox">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="messageButton" runat="server" Text="留言" />   
<asp:Button ID="cancelButton" runat="server" Text="取消" />
</td>
</tr>
<tr>
<td colspan="2" style="color: Black">
<span style="font-size: smaller">本站共有</span>
<asp:Label ID="Label1" runat="server" ForeColor="#C00000" Width="2px"></asp:Label>
<span style="font-size: smaller">位注册会员</span>
</td>
</tr>
</table>
</center>
</div>
<asp:validationsummary runat="server" ID="validationsummary1" ShowMessageBox="true" ShowSummary="false"></asp:validationsummary>
</form>
<div>
<center>
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" style="font-size:32pt; color: White; background-color: #669900">
留言板
</td>
</tr>
<tr>
<td style="font-size: 10pt">
用户名:
</td>
<td style="width: 4px">
<asp:TextBox ID="UserNameTextBox" runat="server" Enabled="false"></asp:TextBox>
</td>
</tr>
<tr>
<td style="font-size: 10pt">
留言主题:
</td>
<td align="left">
<asp:TextBox ID="themeTextBox" runat="server" Width="233px"></asp:TextBox>
<asp:RequiredFieldValidator ID="themeRequiredFieldValidator" runat="server"
ErrorMessage="留言主题不能为空" ControlToValidate="themeTextBox">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td style="font-size: 10pt">
留言内容:
</td>
<td align="left">
<asp:TextBox ID="contentTextBox" runat="server" Height="214px" Width="233px"></asp:TextBox>
<asp:RequiredFieldValidator ID="contentRequiredFieldValidator" runat="server"
ErrorMessage="留言内容不能为空" ControlToValidate="contentTextBox">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="messageButton" runat="server" Text="留言" />   
<asp:Button ID="cancelButton" runat="server" Text="取消" />
</td>
</tr>
<tr>
<td colspan="2" style="color: Black">
<span style="font-size: smaller">本站共有</span>
<asp:Label ID="Label1" runat="server" ForeColor="#C00000" Width="2px"></asp:Label>
<span style="font-size: smaller">位注册会员</span>
</td>
</tr>
</table>
</center>
</div>
<asp:validationsummary runat="server" ID="validationsummary1" ShowMessageBox="true" ShowSummary="false"></asp:validationsummary>
</form>