Wednesday, March 28, 2012

Ajax update panel focus problem

Hi

I have a asp.net 2 web app that uses asp.net ajax and master pages. I have a very common problem that I think most people get when using an update panel and textboxes. The tab order after leaving the text box is lost, so I have heard the fix is to use

Me.ScriptManager1.SetFocus(Textbox1.ClientID);

Rather than adding the ScriptManager to every page I have added it to my Master page. However my update panel exists within a user control, which is then embeded in a master page. So the above syntax does not work in my user control as it does not know about the ScriptManager as it is defined in my master page.

Any ideas on how I could get this to work? Or any other methods to get round this textbox focus problem?

Many thanks inadvance

Use ScriptManager.GetCurrent() to get a reference to the page's ScriptManager.


See for more detail.

http://asp.net/AJAX/Documentation/Live/mref/O_T_System_Web_UI_ScriptManager_SetFocus.aspx


Hi,

You may get reference to the scriptManager instance via
ScriptManager.GetCurrent(this.Page)

Hope this helps.


I'm having a similar problem, except that I have a timer that refreshes some content every 4 seconds. I set the

this.ScriptManager1.SetFocus(tbMessage.ClientID);

but when the content refreshes, it sends the cursor to the beginning of the text box. Even when i'm in the middle of typing something.Tongue Tied

Is there a way to keep the cursor exactly where it was when content was updated in the update panel?

- Albert

(PS - Sorry to hijack this thread.)

No comments:

Post a Comment