Domanda

In this ASP.Net Login Control can you tell me what ID or Name ASP.Net gives the User Name TextBox?

<asp:LoginView 
    ID="loginViewMain" 
    runat="server">

    <LoggedInTemplate>
        <asp:LoginName 
            ID="loginName" 
            runat="server"
            FormatString="Hello, {0}!<br/><br/> You have successfully<br/> logged onto the staff site." />

        <br/>
        <br/>

        (<asp:LoginStatus ID="loginStatus" runat="server" />)

        <br/>
        <br/>

    </LoggedInTemplate>

    <AnonymousTemplate>
        <asp:LoginStatus 
            ID="loginStatus" 
            runat="server" />
    </AnonymousTemplate>
</asp:LoginView>

I would like to set focus on the User Name TextBox once I know what ASP.Net names it from inside a code-behind file.

È stato utile?

Soluzione

If I understand your question correctly, are you look for this?

var loginName = (LoginName)loginViewMain.FindControl("loginName");

Login Control

var usernameTextBox = (TextBox)LoginUser.FindControl("UserName");
userNameTextBox.Focus();
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top