Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to validate the text enter in the textbox after entering the complete in text in the textbox

how to validate the text enter in the textbox after entering the complete in text in the textbox

Scheduled Pinned Locked Moved ASP.NET
databasetutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lakshmichawala
    wrote on last edited by
    #1

    iam having a textbox where iam entering some text say user id then after entering the userid in the textbox and if user goes for next control then how can i validate that the user id entered is already there in my db.which event of the textbox works better.

    C 1 Reply Last reply
    0
    • L lakshmichawala

      iam having a textbox where iam entering some text say user id then after entering the userid in the textbox and if user goes for next control then how can i validate that the user id entered is already there in my db.which event of the textbox works better.

      C Offline
      C Offline
      Caio Kinzel Filho
      wrote on last edited by
      #2

      Well, actually in asp.net you don't have an event on the validation of the control like in windows forms, but you can do like the following: 1) Put a custom validator control in your form 2) Set its ControlToValidate to your Textbox 3) Add a function to your code like

      protected void ValidateTextboxInDB(object source, ServerValidateEventArgs args)
      {
          //Put the result of the validation in: 
          //args.IsValid
      }
      
      1. Bind the event handler to your method like:

        OnServerValidate="ValidateTextboxInDB"
        ControlToValidate="TextBox1"
        ErrorMessage="Your error message.">

      Regards

      Intelligence is almost useless for those who have nothing else! Email: caiokf@gmail.com

      L 1 Reply Last reply
      0
      • C Caio Kinzel Filho

        Well, actually in asp.net you don't have an event on the validation of the control like in windows forms, but you can do like the following: 1) Put a custom validator control in your form 2) Set its ControlToValidate to your Textbox 3) Add a function to your code like

        protected void ValidateTextboxInDB(object source, ServerValidateEventArgs args)
        {
            //Put the result of the validation in: 
            //args.IsValid
        }
        
        1. Bind the event handler to your method like:

          OnServerValidate="ValidateTextboxInDB"
          ControlToValidate="TextBox1"
          ErrorMessage="Your error message.">

        Regards

        Intelligence is almost useless for those who have nothing else! Email: caiokf@gmail.com

        L Offline
        L Offline
        lakshmichawala
        wrote on last edited by
        #3

        hi caiokf Thanks for ur immediate reply .but how to call this when textbox is lost focus means when user enters something in the textbox and comes out.

        B 1 Reply Last reply
        0
        • L lakshmichawala

          hi caiokf Thanks for ur immediate reply .but how to call this when textbox is lost focus means when user enters something in the textbox and comes out.

          B Offline
          B Offline
          balaji t
          wrote on last edited by
          #4

          hi Lakshmi, set ur textbox autopostback property to true in the properties pane of ur textbox. and in the textbox textchange event u can validate the userid against the userid in the DB.This is very simple.

          T.Balaji

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups