Sign in | Join
Last post 08-28-2008 11:12 PM by chetan.sarode. 4 replies.
Sort Posts: Oldest to newest Newest to oldest
Is there any way around this time delay? or is there a better way to set focus?
Thanks,Sara
I have ran into the SetFocus problem..(not exactly the same scenario, but it was with Ajax..)
I used,
ScriptManager scrMgr = ScriptManager.GetCurrent(this.Page);scrMgr.SetFocus(this.textbox1.ClientID);
worked for me!..
HTH
I tried that.. didn't work :( Thanks though!
Did you try calling the code from the event window.onload on the client side?
For example:
window.onload = _onPageLoad;
function _onPageLoad() { // TODO: Set focus
PageLoad should fire after the page has fully loaded.
Hope this helps,-Damien
Sets the browser focus to the specified control
http://www.asp.net/AJAX/Documentation/Live/mref/O_T_System_Web_UI_ScriptManager_SetFocus.aspx
http://gmamaladze.googlepages.com/maintainfocusbetweenpostbacksalsoinasp.n
You can use the following code to set the focus:
ScriptManager sm = ScriptManager.GetCurrent(this);sm.SetFocus(myTextBox);
To set focus and select text of a you have to use the following:
ScriptManager.RegisterStartupScript(this, this.GetType(), "selectAndFocus", "$get('" + myTextBox.ClientID + "').focus();$get('" + myTextBox.ClientID + "').select();", true);
http://forums.asp.net/t/1099345.aspx
http://forums.asp.net/t/1199709.aspx