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. Simple focus??

Simple focus??

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netvisual-studioquestion
4 Posts 4 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.
  • S Offline
    S Offline
    SiliconScout
    wrote on last edited by
    #1

    Hey there. I am writing an ASP.NET program using visual studio basic (VB). I have a page of form fields where users enter in several different numbers and I have validators on each field. What I would like to do is have the textbox recieve focus when the validator kicks in and says the field data is invalid. Thus if I have a field txtBox1 that is validated by fvalTxtB1 I want the txtBox1 to recieve focus if fvaltxtB1 is invalid. I didn't see any setfocus method for the textbox or the validation control so I am expecting that this should be a new method. Anyone already have this kind of code made and willing to save me some time?

    C K 2 Replies Last reply
    0
    • S SiliconScout

      Hey there. I am writing an ASP.NET program using visual studio basic (VB). I have a page of form fields where users enter in several different numbers and I have validators on each field. What I would like to do is have the textbox recieve focus when the validator kicks in and says the field data is invalid. Thus if I have a field txtBox1 that is validated by fvalTxtB1 I want the txtBox1 to recieve focus if fvaltxtB1 is invalid. I didn't see any setfocus method for the textbox or the validation control so I am expecting that this should be a new method. Anyone already have this kind of code made and willing to save me some time?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      The code is easy to find online, it needs to be javascript code, which means you need a custom validator on the client end. Christian Graus - Microsoft MVP - C++

      A 1 Reply Last reply
      0
      • C Christian Graus

        The code is easy to find online, it needs to be javascript code, which means you need a custom validator on the client end. Christian Graus - Microsoft MVP - C++

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        well obvious;y my google skills are failing me here ;) Care to provide a link or two with the code and some explanation for me?

        1 Reply Last reply
        0
        • S SiliconScout

          Hey there. I am writing an ASP.NET program using visual studio basic (VB). I have a page of form fields where users enter in several different numbers and I have validators on each field. What I would like to do is have the textbox recieve focus when the validator kicks in and says the field data is invalid. Thus if I have a field txtBox1 that is validated by fvalTxtB1 I want the txtBox1 to recieve focus if fvaltxtB1 is invalid. I didn't see any setfocus method for the textbox or the validation control so I am expecting that this should be a new method. Anyone already have this kind of code made and willing to save me some time?

          K Offline
          K Offline
          Kareem Shaker
          wrote on last edited by
          #4

          Hi, First it's a common idea to do so but this may cause one usability problem which may make the user frustrated, as for example if you are entering one numeric value into a textbox and you add one validator for this textbox if the user enters an invalid value and presses tab the validator will fire and as the value is invalid the user will not be able to leave this textbox until he enters a valid value, so I recommend that you write on JS function that fires once you try to submit the page and change the bgcolor of all invalid entries to red this may be more better, but if you need to do the focus stuff you can simple write something as : document.Form1.txtKeyWord.focus(); and I think this has been recovered in ASP.NET 2.0 as you can set the focus to one control right from server side code. Kareem Shaker

          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