How to make the text in TexbBox selected

A

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 said:
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 said:
I want the text in a TextBox selected when the TextBox get focus.
How can I do that?
 
E

Eliyahu Goldin

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
 
E

Eliyahu Goldin

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 said:
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 said:
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 said:
I want the text in a TextBox selected when the TextBox get focus.
How can I do that?
 
A

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 said:
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 said:
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 said:
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

I want the text in a TextBox selected when the TextBox get focus.
How can I do that?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,689
Members
48,796
Latest member
Greg L.

Latest Threads

Top