Click here to Skip to main content
15,889,842 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I invoke a focus event on a textbox on an interim page when the page appears? I have a modified version of the custom wizard.
[edit]Code block removed, "Ignore HTML..." option disabled - OriginalGriff[/edit]
[edit]"Removed". The word is "Removed", not "Added" :O - OriginalGriff[/edit]
Posted
Updated 17-Mar-11 9:43am
v3

This may, or may not answer your problem but it won't hurt you to check that tab-order of the controls on the page you are concerned about. Make sure that the TextBox has the lowest number and it should automatically get focus.
 
Share this answer
 
Comments
charles henington 17-Mar-11 18:44pm    
My vote of 5 that is the easiest way to do it on page load with the least amount of code.
Sergey Alexandrovich Kryukov 18-Mar-11 22:26pm    
Henry, I'm not sure your advice will fix the issue completely (and I think my Answer will, please see), but I want to vote 5 anyway, just because tab order is very important; and this aspect is ignored too often, so what you say needs close attention in all cases.
--SA
Sergey Alexandrovich Kryukov 18-Mar-11 22:27pm    
Henry, I'm not sure your advice will fix the issue completely (and I think my Answer will, also the problem is a misconception on what is the event, please see), but I want to vote 5 anyway, just because tab order is very important; and this aspect is ignored too often, so what you say needs close attention in all cases.
--SA
Henry Minute 18-Mar-11 22:41pm    
As my answer said
"This may, or may not answer your problem"

However it is (possibly) the first thing I would look at before looking for logical errors in any code.

Thus far no-one can be sure of anything because the OP has not deigned to honour any of us with a response. IMO if you have to call Focus(), unless it is part of a carefully conceived design, something has gone wrong, somewhere.

In the mean time, you'll have to excuse me because I have consumed a fairly large quantity of alcoholic substances and this is about as coherent as I can be.
Sergey Alexandrovich Kryukov 19-Mar-11 1:51am    
You're right, I should be more accurate. Your advice may or may not solve the problem. Unfortunately, there are cases when you have to call Focus. Focus is more delicate matter then it thought to be. I actually pointed out that calling it "can be a sign of design mistake".
--SA
You cannot invoke a focus event, and event if you could, it would be completely wrong. You should not invoke such even, you should focus, then the event would be invoked as a result. Just call Control.Focus.

Programmatic focusing can be quite reasonable, but in many cases it can be a sign of design mistake. Think about it and review or possible re-think the design very accurately.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900