Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 22nd, 2003, 03:08 PM
Registered User
 
Join Date: Oct 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Giving focus to controls

Here's a simple question... How do you give focus to controls on an aspx page? I have set the Tab Index for all the controls so that they work in the order that I want. But, how do I set the control with tab index #1 to have focus when the page loads?

Oh, and while I'm at it, how do I set the page to accept the Enter key as the equivalent to clicking a button, without having to tab to that button first?

KO
 
Old December 23rd, 2003, 12:42 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default

you can focus on specified control by writing jscript like: document.all.item("txtbox1").focus();

you can also access specified Web Server Control using AccessKey property, you can set to a certain char when pressed with Alt the control is pressed

Ahmed Ali
Software Developer
 
Old January 16th, 2004, 01:37 PM
mow mow is offline
Registered User
 
Join Date: Jan 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

One way I've gotten a form to response to the Enter key is to put a method on the TextChanged event for the text control on the page;

I've not bothered with forms with a lot of text boxes because not all text boxes should necessarily trigger a post-back.

If there's a better way, I'd be interested.

-Martin

 
Old January 16th, 2004, 02:52 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Quote:
quote:Originally posted by KevinO



Oh, and while I'm at it, how do I set the page to accept the Enter key as the equivalent to clicking a button, without having to tab to that button first?

KO
I have never had to add anything for this to work. I have always been able to use the enter key to submit. I use IE with Win XP Pro and I use vs.net 2003. What are you using?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Set Focus to Server controls rwalker ASP.NET 2.0 Basics 3 July 28th, 2006 07:10 AM
This piece of code is giving an error sourik C# 2 July 15th, 2006 09:18 AM
Giving focus back to form Tethys Access VBA 1 March 7th, 2006 03:24 AM
Giving virtual directory own look and feel superkooi Javascript 2 December 27th, 2004 08:19 PM
Giving a program a 'name' Badman3k VB.NET 2002/2003 Basics 2 September 12th, 2004 09:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.