什么叫“又让输一遍口令才行”?-----------------------------------------------------------
<script language=C# runat=server>
void test(object source, EventArgs value){ Response.Write(txtUpwd.Text);
}
</script>
<form runat=server>
<asp:TextBox id="txtUpwd" runat="server" textMode="Password"></asp:TextBox>(**)
<asp:RequiredFieldValidator id="RequiredFieldValidator3" runat="server" ControlToValidate="txtUpwd" ErrorMessage="请输入您的登录口令"></asp:RequiredFieldValidator>
<input type="submit" id="Submit" OnServerClick="test" value="Submit" runat = server/> </form>
-----------------------------------------------------------
<script language=C# runat=server>
void test(object source, EventArgs value){ Response.Write(txtUpwd.Text);
}
</script>
<form runat=server>
<asp:TextBox id="txtUpwd" runat="server" textMode="Password"></asp:TextBox>(**)
<asp:RequiredFieldValidator id="RequiredFieldValidator3" runat="server" ControlToValidate="txtUpwd" ErrorMessage="请输入您的登录口令"></asp:RequiredFieldValidator>
<input type="submit" id="Submit" OnServerClick="test" value="Submit" runat = server/> </form>
-----------------------------------------------------------
<%@ Page Language="VB" %>
<html>
<head>
<script runat="server">
Sub ValidateBtn_Click(sender As Object, e As EventArgs)
If Page.IsValid Then
lblOutput.Text = "Required field is filled!"
Else
lblOutput.Text = "Required field is empty!"
End If
End Sub
</script>
</head>
<body>
<form runat="server">
<h3>RequiredField Validator Example</h3>
<table bgcolor="#eeeeee" cellpadding="10">
<tr valign="top">
<td colspan="3">
<asp:Label ID="lblOutput"
Text="Fill in the required field below"
runat="server"/>
<br>
</td>
</tr>
<tr>
<td colspan="3">
<b>Credit Card Information</b>
</td>
</tr>
<tr>
<td align="right">
Card Number:
</td>
<td>
<asp:TextBox id="TextBox1"
runat="server"/>
</td>
<td>
<asp:RequiredFieldValidator id="RequiredFieldValidator2"
ControlToValidate="TextBox1"
Display="Static"
ErrorMessage="*"
runat="server"/>
</td>
</tr>
<tr>
<td></td>
<td>
<asp:Button id="Button1"
Text="Validate"
OnClick="ValidateBtn_Click"
runat="server"/>
</td>
<td></td>
</tr>
</table>
</form>
</body>
</html>关于验证控件的更详细信息,请参考微软官方网站,并提供有相应的源代码:
http://samples.gotdotnet.com/quickstart/aspplus/
— 微软全球技术中心 VB支持中心本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。