Authentification in ASP.NET Animated with a Progress Bar

Authentification in ASP.NET Animated with a Progress Bar

Its an easy way in order to login into webpages using the login control in asp.net and the membership provider animated with a progress bar.

In the Parsing Xml side, we add a login control and an update progress bar


<asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel id="UpdatePanel1" runat="server">
     <contenttemplate>
        <asp:Login ID="Login1" runat="server"
         
            style="Z-INDEX: 110; LEFT: 350px; POSITION: absolute; TOP: 100px"
            BackColor="White" BorderColor="#F1F6FE" BorderPadding="4" BorderStyle="Solid"
            BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#333333"
            Height="140px" Width="340px"
      UserNameLabelText="ID:" DestinationPageUrl="Welcome.aspx">
       
      <LoginButtonStyle BackColor="White" BorderColor="#41519A" BorderStyle="Solid" BorderWidth="1px"
        Font-Size="0.8em" ForeColor="#41519A" />
    <TextBoxStyle Font-Size="0.8em" />
    <TitleTextStyle BackColor="#2153AA" Font-Bold="True" Font-Size="0.8em" ForeColor="White" />
    <InstructionTextStyle Font-Italic="True" ForeColor="Black" />
    </asp:Login>
</contenttemplate>
</asp:UpdatePanel>
         
<asp:UpdateProgress ID="UpdateProgress1" runat="server" >
            <ProgressTemplate>
                 <img src="images/loadingAnim.gif"  style="Z-INDEX: 110; LEFT: 400px; POSITION: absolute; TOP: 300px"/>
            </ProgressTemplate>
        </asp:UpdateProgress>


In the code behind using vb.net we use the membership provider generated by the visual studio to securise our website.

We add a sleeping thread of 3 second in the event Login1_LoggingIn to let the progress bar show some animation.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       If Not Page.IsPostBack Then
           If Request.IsAuthenticated AndAlso Not String.IsNullOrEmpty(Request.QueryString("ReturnUrl")) Then
 
               Response.Redirect("~/NoAuthorized.aspx")
           End If
       End If
   End Sub
 
   Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate
 
       If Membership.ValidateUser(Login1.UserName, Login1.Password) Then
 
           Dim usrInfo As MembershipUser = Membership.GetUser(Login1.UserName)
 
           e.Authenticated = True
 
       Else
           e.Authenticated = False
       End If
   End Sub
 
   Protected Sub Login1_LoginError(ByVal sender As Object, ByVal e As System.EventArgs) Handles Login1.LoginError
 
       Login1.FailureText = Resources.traduction.failureText
 
   End Sub
   Protected Sub Login1_LoggingIn(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LoginCancelEventArgs) Handles Login1.LoggingIn
       System.Threading.Thread.Sleep(3000)
   End Sub
Leave a Comment
  • Please add 6 and 5 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
Page 1 of 1 (1 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
  • Ed Price - MSFT edited Original. Comment: Tags

  • Thanks, I like your code

Page 1 of 1 (2 items)