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