473,378 Members | 1,334 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

SetFocus

I would like to set the focus automatically to one of the textbox controls
on my page, but so far on every page I load I have to set the cursor to the
textbox by Tab-ing or clicking my mouse in it. I would think that there's a
much simpler way to solve this ...
regards,

Jurjen de Groot
G.I.T.S. Netherlands.
Nov 17 '05 #1
2 3152
Jurjen de Groot

Try putting this code at the end of the page,I think it
goes before the body tag and after the form tag....

<script language=javascript>
document.GetElementById('YourTextboxName').focus()
</script>

dmedina

-----Original Message-----
Perry,

Thanks for your response.
I still have a problem, when I start my ASP.NET project the login formappears, but the user has to click in the 'username' field (or hit tab a fewtimes) to get the cursor into the username field. I'd really like to set thecursor in this field (or ay field for that matter) upon 'page load'.
I've read the KB article but that uses the focus setting after pressing abutton. I can't figure out how to use this on something like a page loadevent.

Kind regards,

Jurjen de Groot
G.I.T.S. Netherlands.
""Perry Deng"" <pe*****@online.microsoft.com> wrote in messagenews:LA**************@cpmsftngxa09.phx.gbl...
At design time, you can use the TabIndex property to specify the tab
order
of each control in the web page. While at running time,
you can use the Focus method to set focus to web control using client- side script.
Please refer to the following article for the sample code: HOW TO: Set Focus to Web Form Controls By Using Client- Side Script http://support.microsoft.com/default.aspx?scid=KB;EN- US;816166
Best regards,
Perry Deng
Microsoft

This posting is provided "AS IS" with no warranties,

and confers norights.

.

Nov 17 '05 #2
Since your using asp.net
in the onpage load event

Me.FieledID.Focus()

So if your field ID is username

Me.Username.Focus()

The advantage to using this method is that ASP.net will handle any browser differences and send client side code appropriate for the requesting browser.

One more note of relevence: In ASP.net the field names are generated at runtime. You can see what they are by looking at the HTML source code of the rendered page.

Happy coding
Mark
Jun 16 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: amy | last post by:
I have a text box, after user input the value, a validate function trigered. if the value is invalid, alert display, and also set focus back to this control. The alert displays, but when the...
4
by: Mad Scientist Jr | last post by:
i am trying to set focus to a specific control depending on the outcome of a validator control and it is not working. none of these methods are working to setfocus: 1....
8
by: Shachar | last post by:
Hi All, I need to start a new process calc for example and when ever the user click on the button the application should setfocus to the calc application. I use this code but it is NOT...
0
by: MrsLeigh | last post by:
I have a datagrid on a web page. In the footer there is a field that should be recieve the focus, either at the start or after a button is clicked to insert the row that is being added in the...
3
by: Jim Devenish | last post by:
In my application vehicles arrive and depart from a workshop. The ArrivalDate and the HandoverDate are each entered. Sometimes the person who should enter the arrival date forgets to do so. ...
12
by: Michael R | last post by:
TabCtrl --- ..............Tab1--Subform1 ..............Tab2--Subform2---TabCtrl2---Tab21 ..........................................................---Tab22...
0
by: srinivasarao yarru | last post by:
hi sir, in access 2003 how we can use the setfocuse property(we have to lostfocuse from one field with in that we have to setfocuse in same field) i am using this code but not setfocuse...
3
by: srinivasarao yarru | last post by:
hi in access 2003 how we can use the setfocuse property(we have to lostfocuse from one field with in that we have to setfocuse in same field) i am using this code but not setfocuse to same field...
5
agroover
by: agroover | last post by:
I can't seem to figure out how to get rid of the errors. I recieve the following error when I leave the Grade.SetFocus in my code... Microsoft Access can't move the focus to the control Grade ...
3
by: ckrows | last post by:
I have a main form with a button that makes a subform visible. I added a button in the form footer of the subform that is supposed to hide the subform. This does not work because the focus is on...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.