Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design 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 February 18th, 2004, 01:25 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default Focus

Does any know how to set the focus to a control in ASP.NET. I can't seem to find a way to do it. Am I missing something or just that dense? Thanks Jim

 
Old February 18th, 2004, 01:31 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You need to write out some javascript to do it. I'm frankly amazed that they didn't add in a feature that let's you do this. Web forms do it automatically when you are using smart navigation, but frankly I don't want some of the overhead and complications of that just to set focus.

Anywhoooo...

RegisterStartupScript(String.Format("<script language=""JavaScript"">document.getElementById("" {0}"").focus();</script>", <web form control to focus on>.ClientID)

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old February 18th, 2004, 02:14 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

I am very suprised too, that's why I thought I was missing something.

Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
Focus dhoward Javascript 3 September 19th, 2007 02:54 AM
Focus dhoward VB.NET 2002/2003 Basics 0 September 13th, 2007 02:23 PM
focus kvanchi General .NET 2 December 13th, 2004 09:16 PM
Focus pbyrum Javascript 2 September 3rd, 2004 04:48 PM





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