Hi
I have an asp.net login control that I have reverted to a template. However I cannot get access to the username and password in code behind, its always null.
Here the html for the control
<asp:Login ID="Login" runat="server" CreateUserText="Not registered?"
CreateUserUrl="Register.as
px" DestinationPageUrl="Defaul
t.aspx" PasswordRecoveryText="Forg
ot your password?"
PasswordRecoveryUrl="Remin
der.aspx" OnAuthenticate="Login_Auth
enticate"
OnLoggedIn="Login_LoggedIn
" SkinID="SampleLogin" TitleText="Login" OnLoginError="Login_LoginE
rror" TextBoxStyle-Width="300px"
Font-Size="Larger" >
<TextBoxStyle Width="300px" />
<LayoutTemplate>
<table border="0" cellpadding="1" cellspacing="0" style="border-collapse: collapse">
<tr>
<td>
<table border="0" cellpadding="0">
<tr>
<td align="center" colspan="2">
Login</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserN
ame">User Name:</asp:Label></td>
<td>
<asp:TextBox ID="UserName" runat="server" Width="300px"></asp:TextBo
x>
<asp:RequiredFieldValidato
r ID="UserNameRequired" runat="server" ControlToValidate="UserNam
e"
ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="Login">*<
/asp:Requi
redFieldVa
lidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Passw
ord">Passw
ord:</asp:
Label></td
>
<td>
<asp:TextBox ID="Password" runat="server" TextMode="Password" Width="300px"></asp:TextBo
x>
<asp:RequiredFieldValidato
r ID="PasswordRequired" runat="server" ControlToValidate="Passwor
d"
ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="Login">*<
/asp:Requi
redFieldVa
lidator>
</td>
</tr>
<tr>
<td colspan="2">
<br />
<asp:CheckBox ID="RememberMe" runat="server" Text="Remember me next time." />
<br />
</td>
</tr>
<tr>
<td align="center" colspan="2" style="color: red">
<br />
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></
asp:Litera
l>
<br />
</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="Login" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:HyperLink ID="CreateUserLink" runat="server" NavigateUrl="Register.aspx
">Not registered?</asp:HyperLink
>
<br />
<asp:HyperLink ID="PasswordRecoveryLink" runat="server" NavigateUrl="Reminder.aspx
">Forgot your password?</asp:HyperLink>
</td>
</tr>
</table>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>
And here is the authenticate event
string id_user = Login.UserName.Trim(); //Get the username from the control - always NULL
string pass_user = Login.Password.Trim(); //get the Password from the control - always NULL
if (Membership.ValidateUser(i
d_user, pass_user))
FormsAuthentication.Redire
ctFromLogi
nPage(id_u
ser, false);
else
login.FailureText = "Login failed. Please try again.";