473,786 Members | 2,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Placing the cursor in a textbox

How is it possible to designate a textbox so that when the .aspx page is
displayed the cursor is already there so the user can just start typing
instead of having to click in the textbox with the mouse first?
thanks,
T
Nov 19 '05 #1
5 2998
javascript: document.forms[0].textboxName.fo cus();

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"Tina" <ti**********@r emovespamexcite .com> wrote in message
news:eK******** ******@TK2MSFTN GP14.phx.gbl...
How is it possible to designate a textbox so that when the .aspx page is
displayed the cursor is already there so the user can just start typing
instead of having to click in the textbox with the mouse first?
thanks,
T

Nov 19 '05 #2
you can use Javascript to do it. Put this in your html code:

<script language=javasc ript>
document.Form1. myTextBox.focus ();
</script>

where Form1 is the name of your form, and myTextBox is the name of your
textbox.

you can also use .select instead of .focus if you want to highlight any
existing text in the box.

"Tina" <ti**********@r emovespamexcite .com> wrote in message
news:eK******** ******@TK2MSFTN GP14.phx.gbl...
How is it possible to designate a textbox so that when the .aspx page is
displayed the cursor is already there so the user can just start typing
instead of having to click in the textbox with the mouse first?
thanks,
T

Nov 19 '05 #3
it doesn't work. a snippet is pasted below. What did I do wrong?
thanks,
T
<meta content="http://schemas.microso ft.com/intellisense/ie5"
name="vs_target Schema">
<script language="javas cript">
document.Form1. tbEmail.focus() ;
</script>
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post" runat="server">
<asp:textbox id="tbEmail" style="Z-INDEX: 100; LEFT: 208px; POSITION:
absolute; TOP: 120px" accessKey="u"
tabIndex="1" runat="server"> </asp:textbox><as p:label id="Label1"
style="Z-INDEX: 101; LEFT: 128px; POSITION: absolute; TOP: 120px"
runat="server"> <u>U</u>sername: </asp:label><asp: textbox id="tbPassword "
style="Z-INDEX: 102; LEFT: 208px; POSITION: absolute; TOP: 184px"
accessKey="p" runat="server" TextMode="Passw ord"
Width="152px"></asp:textbox><as p:button id="btnLogin" style="Z-INDEX: 104;
LEFT: 248px; POSITION: absolute; TOP: 248px"

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:Oy******** ******@tk2msftn gp13.phx.gbl...
javascript: document.forms[0].textboxName.fo cus();

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.

"Tina" <ti**********@r emovespamexcite .com> wrote in message
news:eK******** ******@TK2MSFTN GP14.phx.gbl...
How is it possible to designate a textbox so that when the .aspx page is
displayed the cursor is already there so the user can just start typing
instead of having to click in the textbox with the mouse first?
thanks,
T


Nov 19 '05 #4
it doesn't work. a snippet is pasted below. What did I do wrong?
thanks,
T
<meta content="http://schemas.microso ft.com/intellisense/ie5"
name="vs_target Schema">
<script language="javas cript">
document.Form1. tbEmail.focus() ;
</script>
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post" runat="server">
<asp:textbox id="tbEmail" style="Z-INDEX: 100; LEFT: 208px; POSITION:
absolute; TOP: 120px" accessKey="u"
tabIndex="1" runat="server"> </asp:textbox><as p:label id="Label1"
style="Z-INDEX: 101; LEFT: 128px; POSITION: absolute; TOP: 120px"
runat="server"> <u>U</u>sername: </asp:label><asp: textbox id="tbPassword "
style="Z-INDEX: 102; LEFT: 208px; POSITION: absolute; TOP: 184px"
accessKey="p" runat="server" TextMode="Passw ord"
Width="152px"></asp:textbox><as p:button id="btnLogin" style="Z-INDEX: 104;
LEFT: 248px; POSITION: absolute; TOP: 248px"

"Rob T" <RT*********@DO NTwalchemSPAM.c om> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
you can use Javascript to do it. Put this in your html code:

<script language=javasc ript>
document.Form1. myTextBox.focus ();
</script>

where Form1 is the name of your form, and myTextBox is the name of your
textbox.

you can also use .select instead of .focus if you want to highlight any
existing text in the box.

"Tina" <ti**********@r emovespamexcite .com> wrote in message
news:eK******** ******@TK2MSFTN GP14.phx.gbl...
How is it possible to designate a textbox so that when the .aspx page is
displayed the cursor is already there so the user can just start typing
instead of having to click in the textbox with the mouse first?
thanks,
T


Nov 19 '05 #5
Hello Tina,

I have better luck with:

var ctl = document.getEle mentById('tbEma il');
if (ctl != null) ctl.focus();

--
Matt Berther
http://www.mattberther.com
it doesn't work. a snippet is pasted below. What did I do wrong?
thanks,
T
<meta content="http://schemas.microso ft.com/intellisense/ie5"
name="vs_target Schema">
<script language="javas cript">
document.Form1. tbEmail.focus() ;
</script>
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post" runat="server">
<asp:textbox id="tbEmail" style="Z-INDEX: 100; LEFT: 208px;
POSITION:
absolute; TOP: 120px" accessKey="u"
tabIndex="1" runat="server"> </asp:textbox><as p:label id="Label1"
style="Z-INDEX: 101; LEFT: 128px; POSITION: absolute; TOP: 120px"
runat="server"> <u>U</u>sername: </asp:label><asp: textbox
id="tbPassword "
style="Z-INDEX: 102; LEFT: 208px; POSITION: absolute; TOP: 184px"
accessKey="p" runat="server" TextMode="Passw ord"
Width="152px"></asp:textbox><as p:button id="btnLogin" style="Z-INDEX:
104;
LEFT: 248px; POSITION: absolute; TOP: 248px"

"Rob T" <RT*********@DO NTwalchemSPAM.c om> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
you can use Javascript to do it. Put this in your html code:

<script language=javasc ript>
document.Form1. myTextBox.focus ();
</script>
where Form1 is the name of your form, and myTextBox is the name of
your textbox.

you can also use .select instead of .focus if you want to highlight
any existing text in the box.

"Tina" <ti**********@r emovespamexcite .com> wrote in message
news:eK******** ******@TK2MSFTN GP14.phx.gbl...
How is it possible to designate a textbox so that when the .aspx
page is
displayed the cursor is already there so the user can just start
typing
instead of having to click in the textbox with the mouse first?
thanks,
T


Nov 19 '05 #6

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

Similar topics

25
2675
by: JeffS | last post by:
Honest, I scoured the comp.lang.c.faq for this but found nothing. :) Is there a library function for placing the cursor position in the console? Or is it something that can only be done with a platform API call? I was able to do this in Windows with a Windows.h function, but I want to also do it on Linux/Unix as well. I won't ask for a Linux API call that positions the cursor, as that is
1
3889
by: objectref | last post by:
Hi to all, we have the MousePosition property that we can get the Point of the position of the mouse cursor on the screen, but is it there a way to get the respective Point of a cursor in a TextBox ?? (relative to screen) I mean, i have a textbox that i write some text and i want to know the exact point location of the cursor at any time a character is displayed.
9
4908
by: DotNetShadow | last post by:
Hi Guys, I have been having this problem recently where I have a form with a textbox and button, if in the button event I have the following: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.Cursor = Cursors.WaitCursor Textbox1.text = Now.Tostring System.Threading.Thread.Sleep(2000) ' 2 second wait
2
1466
by: dinny | last post by:
I have a form and a multiline textbox with a message. The problem is that I can see the cursor, is there any way so move the focus away from the textbox so that I don't see the cursor on the form (unless someone actively clicks on the form, that is ok) I tried this, but it didn't work Public Declare Auto Function HideCaret Lib "user32.dll" ( _ ByVal hwnd As IntPtr) As Boolean
1
3161
by: Marc Robitaille | last post by:
Hello I build a usercontrol. On this new control, I added two controls, a TextBox and a ComboBox. My ComboBox is filled with a DataTable. When the user types something in the TextBox, I apply a filter to the DataView of the DataTable of my ComboBox. If there is more than one element, I dropdown the list. If I have one element, it is automatically selected. My problem is that the cursor works badly. When I type for the first time in...
10
3908
by: SHPsalm139 | last post by:
We have an Access 2K application that uses multiple forms. We currently hardcode the release number in a label on each form but this gets tedious to do each time there's a new release. I thought it would be easy to put the new release number in one spot (a table) and have each form reference that table/release number in a text box that I would add to each form but, apparently, it's not as simple as I expected it to be. Would appreciate...
2
3091
by: ThunderMusic | last post by:
Hi, I have a form in which there are many <asp:textbox> tags. When I run the form, we use tab to navigate across the textboxes, but one of our client noticed that when we navigate to some readonly textboxes, the cursor (text cursor, not mouse cursor) disapears and when we tab to the next textbox and come back (shift-tab), not it's ok. Notice that when we navigate to each textbox, the text is automaticaly selected which is not the case for...
13
3387
by: WALDO | last post by:
I have a .Net TextBox (TextBoxBase, really) in which I am appending about 20 lines of text per second. I use the AppendText() method to accomplish this. This is a great substitute for taking the Text property and concatenating it... Me.tb.Text &= newText ' Instead use Me.tb.AppendText(newText) ....ultimately setting the SelectionStart to the end of TextBox, the
3
12005
by: fbergroth | last post by:
Hi, I'm quite new to C# allthough I've been programming in other languages for quite a while. I'd like to change the blinking cursor inside a TextBox, I guess I must derive the class and override the OnPaint()-method, however I have no clue what to do next. I want to be able to switch the blinking cursor to a solid, non-blinking, cursor and preferable have it with a color. So, how should I do that?
0
9650
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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
10164
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...
0
9962
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...
0
8992
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7515
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
6748
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();...
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.