r p

r p

  • NA
  • 343
  • 0

How to access UserName textbox in a LoginView

May 26 2009 9:25 AM

<asp:LoginView ID="LoginView1" runat="server">
    <LoggedInTemplate>
    
            <asp:LoginName ID="LoginName1" runat="server" Font-Names="Arial" Font-Size="10px"
                FormatString="Hello    {0}"/>
          <asp:LoginStatus ID="LoginStatus1" runat="server" Font-Names="Arial" Font-Size="10px"
                    meta:resourcekey="LoginStatus1Resource1" />
     </LoggedInTemplate>
    <AnonymousTemplate>
        <asp:Login ID="Login1" runat="server" DestinationPageUrl="" FailureAction="RedirectToLoginPage"
            OnLoggedIn="OnLoggedIn" Width="100%" Height="60px">
            <LayoutTemplate>           
            <table><tr><td style="height: 42px">
             <table border="0" cellpadding="0" cellspacing="0" width="100%">
                    <tr>
                    <td>
                            <asp:TextBox ID="UserName" runat="server" Font-Names="Arial" Font-Size="10px" onfocus="loginfocus()"
                            TabIndex="1" Width="180px" Height="12px">Enter your email address</asp:TextBox>
</td>
                        <td>
                            <asp:RequiredFieldValidator ID="valRequireUserName" runat="server" ControlToValidate="UserName"
                                meta:resourcekey="valRequireUserNameResource1" SetFocusOnError="True" Text="*"
                                ValidationGroup="Login"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 19px">
                            <asp:TextBox ID="Password" runat="server" Font-Names="Arial" Font-Size="10px" meta:resourcekey="PasswordResource2"
                                TabIndex="2" TextMode="Password" Width="180px" ForeColor="Black" Height="12px">Enter your Password</asp:TextBox></td>
                        <td style="height: 19px">
                            <asp:RequiredFieldValidator ID="valRequirePassword" runat="server" ControlToValidate="Password"
                                meta:resourcekey="valRequirePasswordResource1" SetFocusOnError="True" Text="*"
                                ValidationGroup="Login"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                </table></td>
........
.......
...
</LoginView>
                       
I am trying to access Username textbox(which is in a LoginView control) in the above code in order to show a message.
Can anyone please tell me how to access the UserName textbox in the LoginView?
I am trying the following way, but it gives me error.

<ajaxToolkit:TextBoxWatermarkExtender ID="Tx2" runat="server"
    TargetControlID="UserName"
    WatermarkText="Please enter your Username"
    WatermarkCssClass="watermarked" />

Answers (2)