Yes I do and I just found out that I am being simple!
Dohhh
Forgot to do this
TextBox txtUser = (TextBox)Login.FindControl
string id_user = txtUser.Text;
And it works like a dream!
Main Topics
Browse All TopicsHi
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
PasswordRecoveryUrl="Remin
OnLoggedIn="Login_LoggedIn
<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
<td>
<asp:TextBox ID="UserName" runat="server" Width="300px"></asp:TextBo
<asp:RequiredFieldValidato
ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="Login">*<
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Passw
<td>
<asp:TextBox ID="Password" runat="server" TextMode="Password" Width="300px"></asp:TextBo
<asp:RequiredFieldValidato
ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="Login">*<
</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"></
<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
<br />
<asp:HyperLink ID="PasswordRecoveryLink" runat="server" NavigateUrl="Reminder.aspx
</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
FormsAuthentication.Redire
else
login.FailureText = "Login failed. Please try again.";
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: nouloukPosted on 2007-09-05 at 03:31:37ID: 19831053
Hi mugsey,
Do you use a MembershipProvider ?