MasterPage 및 일부 콘텐츠 페이지가있는이 웹 사이트가 있습니다. MasterPage에는 사용자가 MasterPage에있는 'Log In'링크를 클릭 할 때 팝업되는 div가 있습니다. 이 로그인 양식에는 두 개의 텍스트 상자가 있습니다. 하나는 사용자 이름 용이고 다른 하나는 암호 용입니다. 사용자가 양식을 제출하면 인증을 받아야하며 세션에 사용자 정보가 삽입되어야합니다. 처리 할 코드는 모두 MasterPage 코드 뒤에 있습니다.코드에서 액세스 할 때 MasterPage 텍스트 상자가 비어 있습니다.
다음과 같은 문제가 있습니다. MasterPage 클릭 이벤트가 텍스트 상자의 텍스트를 인증 방법에 사용하기 위해 가져올 때 코드는 텍스트를 비어있는 것으로 봅니다.
무엇이 누락 되었습니까? 사업부
bool IsUserAuthenticated = false;
string userName = txtUserName.Text;
string password = txtPassword.Text;
IsUserAuthenticated = masterDataManager.AuthenticateUser(userName, password);
if (IsUserAuthenticated)
{
Session.Add("UserName", userName);
lblCurrentUserName.Text = "You are logged in as: " + userName;
string script = "<script type=\"text/javascri\">$('#dialogBox').dialog('close');</script>";
if (Page.ClientScript.IsStartupScriptRegistered("closeDialog"))
{
Page.RegisterStartupScript("closeDialog", script);
}
}
else
{
lblLoginError.Text = "Username/Password combination does not exist in the database. Please try again.";
}
을 그리고 여기에 있습니다 : : 여기
버튼 클릭 코드와 그는 마스터 페이지에있는 양식 :ButtonClick
<div id="dialogBox" title="Log In">
<table align="center" style="margin-top: 5px; width: 100%" cellpadding="5" cellspacing="5">
<tr>
<td colspan="2">
<asp:Label ID="lblLoginError" runat="server" Text="" CssClass="errorText"></asp:Label>
</td>
</tr>
<tr>
<td class="dialogText">
<asp:Label ID="lblUserName" runat="server" Text="User Name: " ForeColor="#c3c003"></asp:Label>
</td>
<td class="dialogInput">
<asp:TextBox ID="txtUserName" runat="server" BackColor="Black" ForeColor="#c3c003" Width="210px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="dialogText">
<asp:Label ID="lblPassword" runat="server" Text="Password: " ForeColor="#c3c003"></asp:Label>
</td>
<td class="dialogInput">
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password" BackColor="Black" ForeColor="#c3c003" Width="210px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="dialogInput" colspan="2">
<asp:UpdatePanel runat="server" ID="testupdatepanel">
<ContentTemplate>
<asp:ImageButton ID="btnLogin" runat="server" ImageUrl="~/images/loginout.png" ImageAlign="Right" style="padding-top: 15px;" onclick="btnLogin_Click" />
<asp:ImageButton ID="btnCancel" runat="server" ImageUrl="~/images/cancelout.png" ImageAlign="Right" style="padding-top: 15px;" />
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
</div>
txtUserName 및 txtPassword 텍스트 속성은 상자에 텍스트가 있지만 비어 있습니다.
다른 것이 필요한 경우 알려주십시오.
몇 가지 샘플 코드를 게시 할 수 있습니까? – Don