473,405 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How to make the text in TexbBox selected

ad
I want the text in a TextBox selected when the TextBox get focus.
How can I do that?
Nov 19 '05 #1
4 2280
TextBox renders as <input type=text ...>. This element has a method
select(). Setup a client-side onfocus event like this (c# syntax):

myTextBox.Attributes["onfocus"]="this.selected()";

Eliyahu

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:eR**************@TK2MSFTNGP10.phx.gbl...
I want the text in a TextBox selected when the TextBox get focus.
How can I do that?

Nov 19 '05 #2
ad
I have done that , but it is no effect
My code is:

protected void Page_Load(object sender, EventArgs e)
{
TextBox3.Attributes["onfocus"] = "this.selected()";
}

protected void Button1_Click(object sender, EventArgs e)
{
TextBox3.Focus();
}

But after I click Button1, the text in TextBox3 is not selected.
"Eliyahu Goldin" <re*************@monarchmed.com> ¼¶¼g©ó¶l¥ó·s»D
:#T**************@TK2MSFTNGP15.phx.gbl...
TextBox renders as <input type=text ...>. This element has a method
select(). Setup a client-side onfocus event like this (c# syntax):

myTextBox.Attributes["onfocus"]="this.selected()";

Eliyahu

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:eR**************@TK2MSFTNGP10.phx.gbl...
I want the text in a TextBox selected when the TextBox get focus.
How can I do that?


Nov 19 '05 #3
sorry, should be

TextBox3.Attributes["onfocus"] = "this.select()";

What is Focus()? Are you talking about a web form or a windows form? Or is
it something new in asp.net 2.0?

In asp.net 1.1 you can set focus on a control only on client side.

Eliyahu

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I have done that , but it is no effect
My code is:

protected void Page_Load(object sender, EventArgs e)
{
TextBox3.Attributes["onfocus"] = "this.selected()";
}

protected void Button1_Click(object sender, EventArgs e)
{
TextBox3.Focus();
}

But after I click Button1, the text in TextBox3 is not selected.
"Eliyahu Goldin" <re*************@monarchmed.com> ¼¶¼g©ó¶l¥ó·s»D
:#T**************@TK2MSFTNGP15.phx.gbl...
TextBox renders as <input type=text ...>. This element has a method
select(). Setup a client-side onfocus event like this (c# syntax):

myTextBox.Attributes["onfocus"]="this.selected()";

Eliyahu

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:eR**************@TK2MSFTNGP10.phx.gbl...
I want the text in a TextBox selected when the TextBox get focus.
How can I do that?



Nov 19 '05 #4
ad
Thanks
It do well.
I use Focus() in Asp.Net 2.0.
It mybe the new feature in 2.0.

I have another question.
How to make "enter" key do as "tab" key in Web form.
My users is used "Enter" key to jump from controls to controls.

"Eliyahu Goldin" <re*************@monarchmed.com> ¼¶¼g©ó¶l¥ó·s»D
:u0*************@tk2msftngp13.phx.gbl...
sorry, should be

TextBox3.Attributes["onfocus"] = "this.select()";

What is Focus()? Are you talking about a web form or a windows form? Or is
it something new in asp.net 2.0?

In asp.net 1.1 you can set focus on a control only on client side.

Eliyahu

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I have done that , but it is no effect
My code is:

protected void Page_Load(object sender, EventArgs e)
{
TextBox3.Attributes["onfocus"] = "this.selected()";
}

protected void Button1_Click(object sender, EventArgs e)
{
TextBox3.Focus();
}

But after I click Button1, the text in TextBox3 is not selected.
"Eliyahu Goldin" <re*************@monarchmed.com> ¼¶¼g©ó¶l¥ó·s»D
:#T**************@TK2MSFTNGP15.phx.gbl...
TextBox renders as <input type=text ...>. This element has a method
select(). Setup a client-side onfocus event like this (c# syntax):

myTextBox.Attributes["onfocus"]="this.selected()";

Eliyahu

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:eR**************@TK2MSFTNGP10.phx.gbl...
> I want the text in a TextBox selected when the TextBox get focus.
> How can I do that?
>
>



Nov 19 '05 #5

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

Similar topics

2
by: Imaya Kumar | last post by:
Hi, i'm developing an editor in VS.NET using Rich Text Box Control. I need to make a selected text Bold. how can i do this? also i will have an Italic Button too. If i click Bold button the...
4
by: Dan | last post by:
Can anyone offer suggestions on how to do this or if it is possible? I have a form that uses a drop down box and 2 text fields. What I am trying to do is have the value of each text box set by...
4
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
9
by: john woo | last post by:
Hi Please see the following simple script: <TD align="Left" width="30%" > <select name="DEPARTMENT" SIZE ="1" style="width:200px;" onChange="Change()"> <option value="0"> &lt;ALL&gt...
5
by: Charles | last post by:
Hello, I would like for my users to have a calendar control only when needed. IE button click for the control to appear and then once the date is selected. Populate a text box and the calendar...
2
by: Øyvind Isaksen | last post by:
Mabye this is question is very simple, but I need to make a string-array (in a variable) with the values from a checkbox-list. THANKS :)
8
by: Jeanette White | last post by:
I am trying to create a custom validator to validate that if "Other" is selected from a drop downdown list then a textbox is displayed and a comment is required. The display textbox piece is...
1
by: mlshoats | last post by:
Hello I am trying to make a log to track questions i answer on little hardware problems. I got most of it working but I am very new to programming anything and just started picking up things. I am...
18
by: Academia | last post by:
I let the use modify the text of a combobox and then I replace the selected item with the new text (in Keyup event). But if he sets the Text property to an empty string ("") that sets the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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
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
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...
0
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
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,...

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.