Highlight text in textbox the same way the Firefox address bar on click

any ideas?
LVL 1
addicktzAsked:
Who is Participating?
 
BlackTigerXCommented:
on the form load

textBox1.Click+=new EventHandler(textBox1_Click);

then write the event method

            private void textBox1_Click(object sender, EventArgs e) {
                  (sender as TextBox).SelectAll();
            }
0
 
mistaeverlyCommented:
Javascript is the way to go... posting back to the server is unnessary and seems pretty ungainly to me.
Try:

<asp:textbox id="mytestbox" runat="sever" onfocus="this.select()"></asp:textbox>

This should be the exact functionality you're looking for.
0
 
mistaeverlyCommented:
Betweem BlackTiger and myself, we have given both a Server-side and Client-side solution.  I propose split points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.