+ Reply to Thread
Results 1 to 4 of 4

Implement Validation in our Project

Hybrid View

  1. #1
    joe41
    Guest

    Implement Validation in our Project

    Hello friends,

    How can i implement the validation in our project, means if validation == true then the next page will open else shows an error message.
    please reply.

    Thanks.

  2. #2
    Webtekr
    Guest

    Re: Implement Validation in our Project

    Hi,

    You can implement page validations but,

    Page.Validate is not the same as Page.IsValid (obviously)

    I've never found a reason to call Page.Validate myself (not that there probably aren't some good ones). Here is a contrived example from the help files.

    Sub Page_Load
    If Not IsPostBack
    ' Validate initially to force the asterisks
    ' to appear before the first roundtrip.
    Validate()
    End If
    End Sub
    I always do a check of Page.IsValid first thing in my button click events.

    If Not Page.IsValid Then Return, if (for whatever reason) your client-side javascript didn't prevent the page from posting in the first place then the server validate
    events will run.
    You use Page.IsValid to make sure that the server validation didn't catch anything.

  3. #3
    joe41
    Guest

    Re: Implement Validation in our Project

    Thats very much fine my friend but my need is that i have 2 pages and want to valiadate

    page1 by user name and password.....if the password is correct only then one should

    reach on the next page.

    Thanks very much for this information and please suggest me how can i do that?

  4. #4
    Forum Administrator ExlGuru's Avatar
    Join Date
    03-17-2009
    Location
    India
    MS-Off Ver
    2003,2007
    Posts
    222

    Re: Implement Validation in our Project

    Hi joe,

    Here is the code might help you:

    Option Explicit
    Private Sub cmdOK_Click()
    Dim cn As New ADODB.Connection
    Dim strCNString As String
    Dim rs As New ADODB.Recordset
    Dim Txt As String
    
       On Error GoTo ErrHandler
       'Connect to database
       strCNString = "Data Source=" & App.Path & "\db1.mdb"
       cn.Provider = "Microsoft Jet 4.0 OLE DB Provider"
       cn.ConnectionString = strCNString
       cn.Properties("Jet OLEDB:Database Password") = "jason"
       cn.Open
       'Open recordsource
       With rs
           .Open "Select * from Users where Username='" & txtUserName.Text & "' and Password='" & txtPassword.Text & "'", cn, adOpenDynamic, adLockOptimistic
           'Check username and password
           If .EOF Then
               MsgBox "Access Denied...Please enter correct password!", vbOKOnly + vbCritical, "Security Login"
               txtUserName.Text = ""
               txtPassword.Text = ""
               txtUserName.SetFocus
               cn.Close
           Else
               Txt = "" & " " & UCase$(txtUserName.Text) & ""
               MsgBox "Welcome!!!" & Txt, vbOKOnly + vbExclamation, "Security Login"
               cn.Close
               Unload Me
               frmmain.Show
           End If
       End With
    
    ExitHere:
       Exit Sub
    
    ErrHandler:
       MsgBox Err.Number & " " & Err.Description, vbCritical, "Login ..."
       cn.Close
    End Sub
    ExlGuru

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1