Login Control






< asp:Login id="Login1" runat="server" />




< asp:Login ID="LoginControl" runat="server" BackColor="#F7F6F3" BorderColor="#E6E2D8" TitleText="Login Control" BorderPadding="4" BorderStyle="Solid" BorderWidth="1px" PasswordRecoveryText="Forgot PIN?" Font-Names="Verdana" LoginButtonText="Sign In" UserNameLabelText="Email:" PasswordLabelText="PIN:" Font-Size="0.8em" ForeColor="#333333" Orientation="Horizontal" InstructionText="Please enter Email and Password to Login." HelpPageText="Help" CreateUserText="Register" RememberMeText="Remember Me" onauthenticate="Login1_Authenticate" onloginerror="Login1_LoginError" TextLayout="TextOnTop">
< InstructionTextStyle Font-Italic="True" ForeColor="Black" />
< LoginButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284775" />
< TextBoxStyle Font-Size="0.8em" />
< TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" Font-Size="0.9em" ForeColor="White" />

           



The Attributes are

Attribute Description
id The “ID” for the Login control.
runat runat="server” is needed for all ASP.NET server controls.
CreateUserIconUrl The URL of an image used as a link to the register new user page.          
CreateUserText The text displayed as a link to the register new user page.
CreateUserUrl The URL to the register new user page.
DestinationPageUrl The URL of the page for successful log in. If you don’t specify this attribute, the page which the user was on before getting to this page is displayed.
DisplayRememberMe A checkbox, which is a Boolean, to choose whether the Login Control should automatically let the user save his info by saving a cookie and avoid re-logging in.
FailureText Is the text that will be displayed if the Log in information is not valid. If you do not change this message, a default message“Your login attempt has failed. Please try again” is displayed.
InstructionText A text displayed underneath the title text providing the user with login information. If you do not change this attribute, the default is an empty string.
LoginButtonText The Login button text.
LoginButtonType The button type for the Login button. You can specify “Button”, “Link”, or “Image”. (If you specify “Image”, then you should also specify the LoginButtonImageUrl” attribute.)
Orientation This specifiex the “Horizontal” or “Verticallayout of the login control. If you do not change this attribute, the default is “Vertical”.
PasswordLabelText The text for the “Password” field.
PasswordRecoveryIconUrl The URL for the image used as a link to the recover a lost password page.
PasswordRecoveryText The text for the recover a lost password page.
PasswordRecoveryUrl The URL for the recover a lost password page.
RememberMeText Remember Me check box’s text.
TextLayout Here the position of the labels for the username and password textboxes are set, “TextOnLeft” for the labels to appear on to the left side of the text boxes or “TextOnTop” for the label to appear above the text boxes.
TitleText The text for the top of the Login control.
UserNameLabelText The text for the Username label.

Check The Username and Password Information.
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
Demo.WebServices.Login L = new Demo.WebServices.Login(); //Web Service
System.Web.UI.WebControls.Login LoginControl=(System.Web.UI.WebControls.Login)LoginView1.FindControl("LoginControl");
if (L.Authentication(LoginControl.UserName,LoginControl.Password))
{
Response.Write("< script>alert('Login Success !');");
}
else
{
e.Authenticated = false;
}
}


Check the Login Attempt.
protected void Login1_LoginError(object sender, EventArgs e)
{
if (ViewState["Login"] == null) ViewState["Login"] = 0;
ViewState["Login"] = (int)ViewState["Login"]+1;
if ((int)ViewState["Login"] > 3)
{
Response.Write("< script >alert('Your Credential is More than 3 Times.);'");
}
}


Now Run.