focus on control after an error

S

saurabh

Hey,
I have a form in which there are say 10 fields. I am using validator
control for all the fields. suppose user forgets to fill field no. 5, 8
, 9 and 10.
So on clicking the save button,obviously an error willl be raised. Is
there anyway such that when the error is raised the focus goes to
first control that has false validation (e.g in our case that control
is 5) ? Right now after clicking the save button, none of the control
has the focus.
 
G

Guest

Set the SetFocusOnError portery of the validator control. if you have client
side validation enabled as soon as the user moves out of the textbox, if
there is an error, the focus will immedietly move back to the relevent text
box.
 
S

Siva M

If using ASP.NET 2.0, use SetFocusOnError...

Set the SetFocusOnError portery of the validator control. if you have
client
side validation enabled as soon as the user moves out of the textbox, if
there is an error, the focus will immedietly move back to the relevent text
box.
 
S

saurabh

I am using 1.1.4322 and couldnt find any property like that :( Tell me
is there any workaround ?
what if more than two controls have error. Which control will have the
focus?? in my case i want 5th control to get focus.(basically the
control which is above all other controls having error)
 
G

Guest

Sorry i forgot it's a .net 2.0 thing.

saurabh said:
I am using 1.1.4322 and couldnt find any property like that :( Tell me
is there any workaround ?
what if more than two controls have error. Which control will have the
focus?? in my case i want 5th control to get focus.(basically the
control which is above all other controls having error)
 
K

Kumar Reddi

asp.net 1.1 does not provide this functionality..To do this, you have to
write your own javascript code.
 
S

saurabh

ohh and any idea how to do that in java script ???or any other
workaround exist ?
 
K

Kumar Reddi

If you are using ValidationSummary control to list the error
messages..I will give you a hint, how you can approach the problem..

If you open WebUIValidation.js file, you would see
"ValidationSummaryOnSubmit" function. This function determines if the
page is valid or not.. then if the page is not valid.. it will iterate
through all the invalid validators on the page and get the error
messages from them and list them in a bulleted format or other
according to the way you customize it.. So, you should be able to get
the ID's of all the invalid validator controls from this method.. so
see if you can solve your problem from there..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top