我正在尝试创建一个登录系统,如果用户键入默认密码,它将提示更新密码。
控件都在 UpdatePanel 中,我可以通过在onLoad上使用 UpdatePanel 来强制完全回发控件:
ScriptManager.GetCurrent(Me).RegisterPostBackControl(btnClose)
但是,我有另一个按钮是 btnLogin ,这将检查键入的密码是否为默认密码。如果不是,那么我将做一个完整的回发。以下是我的设计师代码:
<div id="aboutModal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<h3>Sign in with your username and password</h3>
<br/>
<p class="text-justify">
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="txtUsername" runat="server" class="form-control" placeholder="Username"/>
<br />
<asp:TextBox ID="txtPassword" runat="server" class="form-control" placeholder="Password" textmode="Password" />
<br />
<asp:TextBox ID="txtNewPassword" runat="server" class="form-control" placeholder="Update Password" textmode="Password" Visible="false"/>
<br />
<asp:Button ID="btnLogin" runat="server" class="btn btn-primary" Text="Sign in" onclick="btnLogin_Click" />
<asp:Button ID="btnClose" runat="server" Text="Close" class="btn btn-primary" Visible ="true" OnClick="btnClose_Click"/>
</ContentTemplate>
</asp:UpdatePanel>
</p>
<br/>
</div>
</div>
</div>
</div>
这是我背后的代码:
If dbPwd = "pwd123" Then
txtNewPassword.Visible = True
txtUsername.Text = username
txtPassword.Text = pwd
Else
Dim signIn As Control = FindControl("signIn")
Dim logOut As Control = FindControl("logOut")
signIn.Visible = False
logOut.Visible = True
Session("loginDetails") = dbUsername & "," & dbGroup & "," & dbModify & "," & dbRead & "," & dbWrite
'MsgBox(Session("loginDetails"))
txtPassword.Text = ""
txtUsername.Text = ""
dbUsername = ""
dbPwd = ""
btnLogin.Visible = True
End If
问题是如何有条件地将其注册为完全回发的控件?