Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to tell what control is trying to get focus?

Status
Not open for further replies.
Oct 15, 2003
145
US
I have a master/detail datagrid and within the child I have a save button. When I press the button - everything works - the page reloads, saves to my database etc...however I get an error message on the page saying:

Can't Move Focus to the Control because it is invisible, not enabled, or of a type that does not accept the focus.

I am not explicitly setting the focus - so how do I know what control it is trying to set focus to? I know it has something to do with the child datagrid - I'm assuming it's trying to set the focus on it - and it's not visible anymore - but how do I know what object it is trying to set focus to? And how do I change it?

 
you need to find the code that is setting the focus. this could be in js or code behind.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
That's what I thought - but I can't find anything with the word focus in my code or JS. So then I thought maybe when you save a datagrid on the refresh the control automatically goes to the first cell of the datagrid or something. Because my datagrid is no longer visible. But I can't find any documentation or proof that's what's happening.
 
it's not. To my knowledge there is no web control that gets focus by default. This has to be set explicitly by the developer.

create a new webform and build the gridview 1 piece at a time. as you add each piece, debug. if it doesn't break add another, and debug. do this until you can reproduce the error. then track that piece to see where/how it's setting the focus.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top