一般来说,当表单回发之后,密码框将会被自动清空。但是有些时候,我们并不希望这样。
这时,我们可以添加一点的代码将避免这个问题。
VB.NET:
VB.NET
Protected
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Load
If IsPostBack Then
If Not String .IsNullOrEmpty(txtPassword.Text.Trim()) Then
txtPassword.Attributes.Add( " value " , txtPassword.Text)
End If
End If
End Sub
If IsPostBack Then
If Not String .IsNullOrEmpty(txtPassword.Text.Trim()) Then
txtPassword.Attributes.Add( " value " , txtPassword.Text)
End If
End If
End Sub
C#:
C#
protected
void
Page_Load(
object
sender, EventArgs e)
{
if (IsPostBack)
{
if ( ! (String.IsNullOrEmpty(txtPassword.Text.Trim())))
{
txtPassword.Attributes[ " value " ] = txtPassword.Text;
}
}
}
{
if (IsPostBack)
{
if ( ! (String.IsNullOrEmpty(txtPassword.Text.Trim())))
{
txtPassword.Attributes[ " value " ] = txtPassword.Text;
}
}
}
(全文完)
以下为广告部分
您部署的HTTPS网站安全吗?
如果您想看下您的网站HTTPS部署的是否安全,花1分钟时间来 myssl.com 检测以下吧。让您的HTTPS网站变得更安全!
快速了解HTTPS网站安全情况。
安全评级(A+、A、A-...)、行业合规检测、证书信息查看、证书链信息以及补完、服务器套件信息、证书兼容性检测等。
安装部署SSL证书变得更方便。
SSL证书内容查看、SSL证书格式转换、CSR在线生成、SSL私钥加解密、CAA检测等。
让服务器远离SSL证书漏洞侵扰
TLS ROBOT漏洞检测、心血漏洞检测、FREAK Attack漏洞检测、SSL Poodle漏洞检测、CCS注入漏洞检测。