473,748 Members | 2,578 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to give control focus when page loads

Just wondering if there is a way to give a control focus when the page loads, for example so the user could start typing in a text box before clicking on it?
Thanks,
--
Paul G
Software engineer.
Nov 18 '05 #1
3 1828
Paul,

You can do it in a javascript. Setup an onload event for the <body> tag. In
the event handler put a line
myForm.myContro l.focus();

Eliyahu

"Paul" <Pa**@discussio ns.microsoft.co m> wrote in message
news:A1******** *************** ***********@mic rosoft.com...
Just wondering if there is a way to give a control focus when the page loads, for example so the user could start typing in a text box before
clicking on it? Thanks,
--
Paul G
Software engineer.

Nov 18 '05 #2
Is it possible to give control focus using Asp.net code??

"Paul" <Pa**@discussio ns.microsoft.co m> wrote in message
news:A1******** *************** ***********@mic rosoft.com...
Just wondering if there is a way to give a control focus when the page loads, for example so the user could start typing in a text box before
clicking on it? Thanks,
--
Paul G
Software engineer.

Nov 18 '05 #3

See this article
http://www.dotnetspider.com/Technology/KBPages/222.asp
-
tonymjoh
-----------------------------------------------------------------------
Posted via http://www.codecomments.co
-----------------------------------------------------------------------

Nov 18 '05 #4

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

Similar topics

5
9671
by: Mike Hnatt | last post by:
I'd like the focus to be on "mycontrol" when the page is first loaded. I'm getting an undefined error and am assuming that I can't do this in the body ONLOAD event because the control is not yet rendered. (but I thought this would still work) <body onload="mycontrol.focus()"> Also, is there a way to not produce an error if that control does not exist? Thanks!
2
1426
by: Christian Ista | last post by:
Hello, I found that (see below) to give the focus to a control(textbox) on an asp.net page. There is no easiest way to do that ? Thanks, System.Text.StringBuilder sb = new System.Text.StringBuilder(""); sb.Append("<script language=\"JavaScript\">");
1
1242
by: Stuart | last post by:
Hi there I am trying to introduce some dynamic control focus in to my asp application by turning the <body> of the aspx file in to an HTML Server control. I have read elsewhere that if you assign an ID to the <body> as well as runat="server" : e.g. <body id="PageBody" runat="server">
2
2005
by: parm | last post by:
How do I highlight text in my first (tabindex = 1) asp control (eg: textbox) on the webform on page load. If I try to set focus using javascript then I get script error "Cannot move focus to invisible control)". Because the tabindex of first control is 1 therfore I can get the focus on first control but the text inside is not highlighted. Any help would be greatly appriciated. My set focus javascript: Public Sub SetFocus(ByRef MyPage As...
4
1929
by: Aung Thu | last post by:
Hi, there! I want to set focus on a control, of which TabIndex is not the first, when a form is loaded. In the form's load event, I have used Control.Focus() but it doesn't not work. The focus is not on the control I set. The focus is always on the control of which TabIndex is 0. Thanks.
5
10905
by: punchbag | last post by:
Hi all, There has recently been a new update to internet explorer whereby activex controls now load on a page unactivated. MSDN have a website explaining a workaround where you do away with the <OBJECT> tag in your html and instead use an external Javascript the control will load activated. http://msdn.microsoft.com/library/?url=/workshop/author/dhtml/overview/activating_activex.asp
1
2553
by: Dan Sikorsky | last post by:
My ASP.Net 2.0 FormView has an EditItemTemplate, an InsertItemTemplate and an ItemTemple. When the page first loads, the ItemTemplate shows with an Edit button. If the user clicks the Edit button, the postback loads the EditItemTemplate, but with NO focus on any control on the EditItemTemplate. How can I set the focus to the first textbox on the EditItemTemplate when the page postsback? -- Dan Sikorsky, MSCS BSCE BAB
4
4062
by: Jason | last post by:
Hi, Here's the scenario: I have a web application that has window A and window B. A user has both window A and B open - window A is in the foreground and window B is behind it. If the user looking at window A clicks the "open window B" link, I want
3
2437
by: zacks | last post by:
I am working on an application that has a UI that supports multiuple functions by means of a group of "plug ins". Each plugin is a class library. Each plugin contains a User Control that defines the controls for that plugin's main form. The UI has a PictureBox control that is nothing but a contain to add the UserControl from the selected plugin, so that when the user selects a plugin, the main form changes appearance to the UserControl in...
0
9562
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9386
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.