469,267 Members | 1,094 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,267 developers. It's quick & easy.

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 2172
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> 撰寫於郵件新聞
:#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> 撰寫於郵件新聞
:#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> 撰寫於郵件新聞
: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> 撰寫於郵件新聞
:#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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Imaya Kumar | last post: by
4 posts views Thread by Oscar Monteiro | last post: by
9 posts views Thread by john woo | last post: by
2 posts views Thread by 喕vind Isaksen | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.