Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

finding controls inside the longinview

Status
Not open for further replies.

rromeo407

Programmer
May 7, 2012
2
0
0
US
I have a login form on my page that works correctly but when I added the loginview I could no longer see the login1.username or the login1.password in the code behind page, how can I find them? i have been trying for a while.
Code:
<asp:LoginView ID="LoginView1" runat="server">
    <AnonymousTemplate>
    <asp:Login ID="Login1" runat="server" BackColor="#F7F7DE" BorderColor="#CCCC99" 
        BorderStyle="Solid" BorderWidth="1px" DestinationPageUrl="~/login.aspx" 
        FailureText="wrong email or password" Font-Names="Verdana" Font-Size="10pt" 
        onauthenticate="Login1_Authenticate" RememberMeText="Remember me " 
        UserNameLabelText="Email:" VisibleWhenLoggedIn="true" Width="347px">
        <TitleTextStyle BackColor="#6B696B" Font-Bold="True" ForeColor="#FFFFFF" />
    </asp:Login>
                    <asp:LoginStatus ID="LoginStatus1" runat="server" />
                </AnonymousTemplate>
                <LoggedInTemplate>
                    <asp:LoginStatus ID="LoginStatus2" runat="server" />
                </LoggedInTemplate>
                </asp:LoginView>
Code:
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
        
        string userName = LoginView1.FindControl("Login1.UserName");
        string password = LoginView1.FindControl("Login1.password");

        bool result = UserLogin(userName, password);
        if ((result))
        {
            e.Authenticated = true;
        }
        else
        {
            e.Authenticated = false;
        }

    }
 
Are you getting a compilation error or does loginview1.findcontrol... not return a value?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top