As title, druing a button-click post back, I set a control, say Button1, to get the focus by Button1.Focus();
However, after the page is rendered, the Button1 still do not gets the focus as if browser window itself gets the focus instead.
Could any body give me some tips the find out the problem?
Note: The page is copied from an existing one and do some modification.
Thanks a lot
Ricky
Regards
it could be that the page is focusing somewhere else due to javascript, or just the browser...
but if you add the following code to your page, you should be able to re-focus where you want it... (add this code at the bottom of your page with the Page.ClientScript.RegisterStartupScript method):
setTimeout(function() { document.getElementById("myTextBox's Client Side ID here...").focus(); }, 250); <-- this will do it after 250 milliseconds (adjust to your needs).
Peace,
Nullable:
it could be that the page is focusing somewhere else due to javascript, or just the browser...
but if you add the following code to your page, you should be able to re-focus where you want it... (add this code at the bottom of your page with the Page.ClientScript.RegisterStartupScript method):
setTimeout(function() { document.getElementById("myTextBox's Client Side ID here...").focus(); }, 250); <-- this will do it after 250 milliseconds (adjust to your needs).
Peace,
Thanks. I have found the bug caused by the invalid HTML markups.
Ricky
0 comments:
Post a Comment