Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 April 1st, 2004, 09:17 AM
Registered User
 
Join Date: Apr 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to set focus in ASP.NET

HI:
    I has develop a web tool for my company, the tool's function is very simple:operator input a SN in a textbox, then the tool will display the result under the textbox, but I don't know how to set the focus on this textbox, it is very inconvenience for operator to click the textbox everytime. Please help me! Very thanks

Liuyan

 
Old April 1st, 2004, 09:19 AM
Authorized User
 
Join Date: Jan 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I haven't actually done this yet, but try this article
http://www.reflectionit.nl/InitialFocus.aspx
mark

 
Old April 1st, 2004, 01:14 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

You can also use javascript to do this also.
 
Old April 3rd, 2004, 03:47 PM
Registered User
 
Join Date: Apr 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks you!!!

Nickliuyan

 
Old April 24th, 2004, 06:08 PM
Registered User
 
Join Date: Apr 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 This is in response to the URL you posted above:

http://www.reflectionit.nl/InitialFocus.aspx

I have been looking all over for a VB version of that code and can't find it.

I have used a C# to VB converter vut when running this code, I get an error that says:

Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not valid.


Line 41:
Line 42: ' Set Focus on the selected item of a RadioButtonList
Line 43: Dim rbl As RadioButtonList = control
Line 44: If Not (rbl Is Nothing) Then
Line 45: Dim suffix As String = "_0"

Here is that function in VB.

' Set Focus on the selected item of a RadioButtonList
                Dim rbl As RadioButtonList = control
                If Not (rbl Is Nothing) Then
                    Dim suffix As String = "_0"
                    Dim t As Integer = 0
                    Dim li As ListItem
                    For Each li In rbl.Items
                        If li.Selected Then
                            suffix = "_" + t.ToString()
                            Exit For
                        End If
                        t += 1
                    Next li
                    s.Append(suffix)
                End If
 
Old May 1st, 2004, 07:18 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What is "control" in the context of your code?

"Control" is a .net type so this is probably what's causing the problem.





Similar Threads
Thread Thread Starter Forum Replies Last Post
set focus sameer_1981 Intro Programming 1 February 27th, 2007 09:14 AM
set focus akibaMaila VB.NET 2002/2003 Basics 1 July 12th, 2005 05:56 PM
focus not being set correctly mfisher_jr Access VBA 1 July 27th, 2004 08:43 PM
how to set focus waley .NET Web Services 1 May 25th, 2004 02:38 PM





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