获取的姓名或用户名文本框的ID从一个ASP.Net登录控制 [英] Getting the name or ID of the User Name TextBox from an ASP.Net Login Control

查看:100
本文介绍了获取的姓名或用户名文本框的ID从一个ASP.Net登录控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此ASP.Net登录控制你能告诉我什么编号或名称,ASP.Net提供用户名文本框?

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>

我想将焦点设置在用户名文本框一旦我知道ASP.Net它的名字从code-隐藏文件里面。

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.

推荐答案

如果我正确地理解你的问题,你看这个?

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

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

登录控制

var usernameTextBox = (TextBox)LoginUser.FindControl("UserName");
userNameTextBox.Focus();

这篇关于获取的姓名或用户名文本框的ID从一个ASP.Net登录控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆