关于webform textbox Password 模式

textbox在这个模式时,如果进行点击按钮或者其他与后台交互的操作,则状态不会保留,既密码框内容会被清空;

这个可以在前台使用 隐藏控件加js获取密码框内容赋值到隐藏控件,点击刷新后通过后台为密码框重新赋值

后台为密码框赋值可以使用txtAcnt_Pwd.Attributes.Add("value", HiddenPwd.Value);来赋值

 

转载于:https://www.cnblogs.com/yellowcool/p/7656351.html

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="WebForm1.aspx.cs" Inherits="WebForm1" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>用户注册</title> <style type="text/css"> .error { color: red; } </style> </head> <body> <form id="form1" runat="server"> <div> <label for="txtName">姓名:</label> <asp:TextBox ID="txtName" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtName" ErrorMessage="用户必须填写" ForeColor="Red" Display="Dynamic"></asp:RequiredFieldValidator> </div> <div> <label for="txtPassword">密码:</label> <asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtPassword" ValidationExpression="^.{8,}$" ErrorMessage="密码必须八位以上" ForeColor="Red" Display="Dynamic"></asp:RegularExpressionValidator> </div> <div> <label for="txtConfirmPassword">确认密码:</label> <asp:TextBox ID="txtConfirmPassword" runat="server" TextMode="Password"></asp:TextBox> <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="txtConfirmPassword" ControlToCompare="txtPassword" ErrorMessage="两次密码必须一致" ForeColor="Red" Display="Dynamic"></asp:CompareValidator> </div> <div> <label for="txtPhone">手机号:</label> <asp:TextBox ID="txtPhone" runat="server"></asp:TextBox> <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtPhone" ValidationExpression="^1[35789][0-35-9]\d{8}$" ErrorMessage="手机号格式不正确" ForeColor="Red" Display="Dynamic"></asp:RegularExpressionValidator> </div> <div> <label>请修正以下错误:</label> <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowSummary="true" ShowMessageBox="false" HeaderText="" CssClass="error"></asp:ValidationSummary> </div> <div> <asp:Button ID="btnRegister" runat="server" Text="注册" OnClick="btnRegister_Click" /> </div> </form> </body> </html>
最新发布
05-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值