472,353 Members | 1,387 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 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 2237
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...
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...
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...
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;"...
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...
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...
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...
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...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

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.