Login form Demo (VB.net) : Log In « Components « ASP.Net

Home
ASP.Net
1.ADO.net Database
2.Ajax
3.Asp Control
4.Collections
5.Components
6.Data Binding
7.Development
8.File Directory
9.HTML Control
10.Language Basics
11.Login Security
12.Mobile Control
13.Network
14.Page
15.Request
16.Response
17.Server
18.Session Cookie
19.Sitemap
20.Theme Style
21.User Control and Master Page
22.Validation by Control
23.Validation by Function
24.WebPart
25.WPF
26.XML
ASP.Net » Components » Log In 
Login form Demo (VB.net)

<%--
Code revised from 

ASP.NET Tips & Techniques (Paperback)
by Greg Buczek 


# Publisher: McGraw-Hill/Osborne Media; 1st edition (May 212002)
# Language: English
# ISBN: 0072225149

--%>   

<%@ Page Language=VB Debug=true %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OLEDB" %>
<script runat=server>
Sub SubmitBtn_Click(Sender As Object, E As EventArgs)
    Dim DBConn as OleDbConnection
    Dim DBCommand As OleDbDataAdapter
    Dim DSLogin as New DataSet
    DBConn = New OleDbConnection("PROVIDER=" _
        "Microsoft.Jet.OLEDB.4.0;" _
        "DATA SOURCE=" _
        & Server.MapPath("LogIn.mdb;"))
    DBCommand = New OleDbDataAdapter _
        ("Select UserID from " _
        "Users Where " _
        "UserName = '" & txtUserName.Text _
        "' and Password = '" & txtPassword.Text _
        "'", DBConn
    DBCommand.Fill(DSLogin, _
        "UserInfo")
    If DSLogin.Tables("UserInfo"). _
        Rows.Count = Then
        lblMessage.Text = "The user name and password " _
            "were not found. Please try again."
    Else
        Session("UserID"= DSLogin.Tables("UserInfo"). _
            Rows(0).Item("UserID")
        Session("UserName"= txtUserName.Text
        Response.Redirect("./welcome.aspx")
    End If
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Log In Page</TITLE>
</HEAD>
<form runat="server">
<asp:Label 
    id="lblMessage" 
    Font-Size="12pt"
    Font-Name="Tahoma"
    runat="server"
    Text="Complete each field to enter the site."
/>
<P></P><Font Face="Tahoma">User Name:</Font><BR>
<asp:TextBox 
    id="txtUserName" 
    Columns="25"
    MaxLength="50"
    runat=server 
/>
<asp:RequiredFieldValidator 
    id="rfvUserName"
    ControlToValidate="txtUserName"
    Display="Dynamic"
    Font-Name="Tahoma"
    Font-Size="10pt"
    runat=server>
    User Name is Required!
</asp:RequiredFieldValidator>
<P></P><Font Face="Tahoma">Password:</Font><BR>
<asp:TextBox 
    id="txtPassword" 
    Columns="25"
    MaxLength="50"
    runat=server 
    TextMode="Password"
/>
<asp:RequiredFieldValidator 
    id="rfvPassword"
    ControlToValidate="txtPassword"
    Display="Dynamic"
    Font-Name="Verdana"
    Font-Size="10pt"
    runat=server>
    Password is Required!
</asp:RequiredFieldValidator><BR><BR>
<asp:button 
    id="butOK"
    text="  OK  "
    OnClick="SubmitBtn_Click" 
    runat="server"
/>
</form>
</BODY>
</HTML>

<%-- Welcome.aspx

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    If Len(Session("UserID")) Then
        Response.Redirect("./login.aspx")
    End If
    lblMessage.Text = "Welcome: " & Session("UserName")
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Welcome Page</TITLE>
</HEAD>
<form runat="server">
<asp:Label 
    id="lblMessage" 
    Font-Size="12pt"
    Font-Name="Tahoma"
    runat="server"
/>
</form>
</BODY>
</HTML>

--%>
           
       
LogIn.zip( 8 k)
Related examples in the same category
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.