View Full Version : Problem With Switch Content Script

Wee Bubba
09-01-2005, 06:01 AM
first of all, thanks to whoever supplied this free script. it has saved me a lot of time and effort!

i am having a small problem with it and wonder if somebody might help me.

i am designing an ASP.NET page and I have put a dropdownlist inside one of the dynamic layers. when my DropDownList posts back i am trying to set the focus back to it by doing this:


i notice that if I remove the 'Switch Content Script' then my DropDownList focuses ok after a post back. otherwise I get the error message saying it can't set focus on my control because its not there.

i presume this is something to do with the chain of events i.e. my focus script is trying to set focus to a control which has not yet been revealed by the Show/Hide script. however i have tried placing my focus script right at the end of the page and it still wont work.

can anyone help me?

Wee Bubba
09-06-2005, 11:16 AM
can anyone help me with this issue pls?

09-06-2005, 01:56 PM
If memory serves, switch content works by rendering display='none' for those sections waiting in the wings, as it were. You cannot give focus to such an element or one contained in such an element. I ran into something similar with a text input field inside one of these switch content divisions. The solution there was to go to the section in the script where content is inserted/removed from the flow of the document and adding in some language to test if the input's containing division's display property was set to 'block', set focus on the input element. If you need help doing this or adapting it to your situation:


Wee Bubba
09-06-2005, 10:37 PM
hello john thanks for your reply.

i apologise that my thread was not in the correct format it is my first post and i must confess that i did not read the sticky.

i will go away and spend some time trying to fix this for myself going off what you've just told me. if not i will create a new post in the correct format and attach a URL example.