Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
First form field gets focus
Message
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
00672492
Message ID:
00673034
Vues:
19
Thanks Cathi,

I had realized it was a form button that would not give up initial focus no matter how loud I yelled at it. I finally removed it and just used the javascript and AutoPostBack and viola!

Thanks for the reply..


-Ed

>As with so much of .NET there is multiple ways to handle this:
>
>Option 1:
>The objects on a ASP.NET webform have a property called "TabIndex" whichever item has the TabIndex of 1 should get the focus. (if more than one object has 1, then they are focused in the order they are declared). However, this does not work until the user presses the Tab key. The first focus they will always get is the address bar then the control that has the TabIndex of 1.
>
>Option 2:
>Create your own Focus Manager. Here a link about how to do this:
>http://www.devx.com/dotnet/articles/rj121801/rj121801-1.asp
>
>Option 3:
>Use javascript to set the focus. Place the code in the Form's Load event. Here is the syntax:
>
>
>Dim script As String = "<script language=javascript> MyFormID." & _
>    MyControl.ClientID.ToString() + ".focus();</script>"
>RegisterStartupScript("focus", script)
>
>
>Substitute MyFormID with the Form name that appears in the HTML tab of your ASP.NET page like the following:
>
><form id="MyFormID" method="post" runat="server">
>
>
>Also substitute MyControl with the name of the control you want to have focus.
>
>
>>Hello all,
>>
>>Does anyone know how to force and aspx page to set focus to the first field that appears within. I would of thought there would be a way in ASP.NET as a property setting, but not that I can find.
>>
>>Javascript solutions that worked in ASP are not working in ASP.NET
>>
>>Any help is greatly appreciated.
>>
>>Many thanks,
>>Ed
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform