473,503 Members | 7,823 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to put cursor in textbox onload

I really really really need to put the cursor in a text box at onload.
I can't figure out how to do this in ASP.NET. Anyone? In ASP.NET,
javascript, anything ...
Nov 18 '05 #1
1 3708
Hi asadikhan,

you can use the following sample script to do this, Replace the TextBox1
with the name of the control to which you want to set the focus to

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
StringBuilder myJavaScript = new StringBuilder();

myJavaScript.Append("<script language='Javascript'> function
setfocus(){");
myJavaScript.Append("document.getElementById(\"" +
TextBox1.ClientID + "\").focus();");
myJavaScript.Append("} setfocus();</script>");

this.RegisterStartupScript("SetFocusScript",
myJavaScript.ToString());
}

HTH
Regards
Ashish M Bhonkiya

<as*******@hotmail.com> wrote in message
news:fd*************************@posting.google.co m...
I really really really need to put the cursor in a text box at onload.
I can't figure out how to do this in ASP.NET. Anyone? In ASP.NET,
javascript, anything ...

Nov 18 '05 #2

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

Similar topics

2
5861
by: Xam | last post by:
Hello Everybody Can you let me know of a javascript/dom routine that will automatically put the flashing cursor in the first text box in my form so that it is ready for entry rather than the...
1
3819
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...
1
9710
by: Olav Tollefsen | last post by:
I use this code to set focus to a textbox when I load a page: private void SetFocus(System.Web.UI.Control ctrl) { string s = "<SCRIPT language=\"javascript\">document.getElementById('" +...
9
4851
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...
2
1455
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...
1
3131
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...
2
3069
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...
13
3309
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...
3
11917
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...
0
7067
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...
0
7264
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,...
0
7316
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...
1
6975
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...
0
4666
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...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1495
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 ...
0
371
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...

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.