469,623 Members | 1,520 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,623 developers. It's quick & easy.

Ajax.Net and control focus

Hello,

I am starting the use the new ajax.net and I am seeing a bizarre
behavior when controlling focus from the codebehind.

I have tried:

<control>.focus
page.setfocus(<control>)
CType(Master.FindControl("<form id>"), HtmlForm).DefaultFocus =
<control>.ClientID

None of them seem to work. Is there something obvious I am doing
weird? Maybe these methods depend on the body onload, which doesn't
fire . . . is there a way around this?

Thanks and have a great evening,
Ryan

Feb 28 '07 #1
1 2697
Nevermind, thanks to this article:

http://www.codeproject.com/useritems...ocusASPNET.asp

I was able to use this:

ScriptManager.RegisterStartupScript(<control>, Me.GetType, "SetFocus",
"document.getElementById('" + <control>.ClientID + "').focus()", True)

Big thanks to George!

Ryan
On Feb 27, 8:53 pm, "Ryan" <ryan.mcl...@gmail.comwrote:
Hello,

I am starting the use the new ajax.net and I am seeing a bizarre
behavior when controlling focus from the codebehind.

I have tried:

<control>.focus
page.setfocus(<control>)
CType(Master.FindControl("<form id>"), HtmlForm).DefaultFocus =
<control>.ClientID

None of them seem to work. Is there something obvious I am doing
weird? Maybe these methods depend on the body onload, which doesn't
fire . . . is there a way around this?

Thanks and have a great evening,
Ryan

Feb 28 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by pmclinn | last post: by
2 posts views Thread by soni2926 | last post: by
4 posts views Thread by ton | last post: by
3 posts views Thread by =?Utf-8?B?Y21lZWsxXzE5OTk=?= | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.