Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Asp.Net equivalent of VFP control.setfocus
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00708825
Message ID:
00709087
Views:
35
Another approach, although it is still javascript, is to include code in your code behind. Just put the following inside of your Page_Load method:
Dim script As String = "<script language=javascript> document.forms[0]." & _
    txtMyControl.ClientID.ToString() + ".focus();</script>"
RegisterStartupScript("focus", script)
Just substitute "txtMyControl" with the name of the Control you want to set focus to.

>Hi Douglas,
>
>Using "elements[1]" instead of "button1" did the trick.
>
>< body onload="document.forms[0].elements[0].focus();" > - [] not ().
>
>Im going to play around with a VB.Net solution, such as CONTROL.FOCUS(), in the page load event of my form, since Im not real excited about adding another language (javascript) to my bag of tricks unless I have to.
>
>For now though, Im doing it your way...
>
>Many thanks for your help!
>
>Todd
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform