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