473,573 Members | 2,903 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2286
TextBox renders as <input type=text ...>. This element has a method
select(). Setup a client-side onfocus event like this (c# syntax):

myTextBox.Attri butes["onfocus"]="this.selected ()";

Eliyahu

"ad" <ad@wfes.tcc.ed u.tw> wrote in message
news:eR******** ******@TK2MSFTN GP10.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(objec t sender, EventArgs e)
{
TextBox3.Attrib utes["onfocus"] = "this.selected( )";
}

protected void Button1_Click(o bject sender, EventArgs e)
{
TextBox3.Focus( );
}

But after I click Button1, the text in TextBox3 is not selected.
"Eliyahu Goldin" <re************ *@monarchmed.co m> 撰寫於郵件新聞
:#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.Attri butes["onfocus"]="this.selected ()";

Eliyahu

"ad" <ad@wfes.tcc.ed u.tw> wrote in message
news:eR******** ******@TK2MSFTN GP10.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.Attrib utes["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.ed u.tw> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
I have done that , but it is no effect
My code is:

protected void Page_Load(objec t sender, EventArgs e)
{
TextBox3.Attrib utes["onfocus"] = "this.selected( )";
}

protected void Button1_Click(o bject sender, EventArgs e)
{
TextBox3.Focus( );
}

But after I click Button1, the text in TextBox3 is not selected.
"Eliyahu Goldin" <re************ *@monarchmed.co m> 撰寫於郵件新聞
:#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.Attri butes["onfocus"]="this.selected ()";

Eliyahu

"ad" <ad@wfes.tcc.ed u.tw> wrote in message
news:eR******** ******@TK2MSFTN GP10.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.co m> 撰寫於郵件新聞
:u0************ *@tk2msftngp13. phx.gbl...
sorry, should be

TextBox3.Attrib utes["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.ed u.tw> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
I have done that , but it is no effect
My code is:

protected void Page_Load(objec t sender, EventArgs e)
{
TextBox3.Attrib utes["onfocus"] = "this.selected( )";
}

protected void Button1_Click(o bject sender, EventArgs e)
{
TextBox3.Focus( );
}

But after I click Button1, the text in TextBox3 is not selected.
"Eliyahu Goldin" <re************ *@monarchmed.co m> 撰寫於郵件新聞
:#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.Attri butes["onfocus"]="this.selected ()";

Eliyahu

"ad" <ad@wfes.tcc.ed u.tw> wrote in message
news:eR******** ******@TK2MSFTN GP10.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
2423
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 Italic Button too. If i click Bold button the selected text has to become bold, and if i click italic button, the bolded text has to become Italic too with the bolded attribute. how can i do this?...
4
6293
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 trying to do is have the value of each text box set by the choice from the drop down box. Something like: <form name="populatefrm" id="contactfrm" method="post"
4
3264
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 value=3> <br> <input type="radio" name=p2 value=1> <input type="radio" name=p2 value=2> <input type="radio" name=p2 value=3> then a text area and a button:
9
1586
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;" onChange="Change()"> <option value="0"> &lt;ALL&gt <option value="1000012" >Food Sales <option value="1000014" >Dessert Sales
5
4312
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 selected. Populate a text box and the calendar control then is invisible. How do I make the calendar control pop up over other control in a asp.net c# environment? Charles
2
6889
by: 喕vind 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
3120
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 is required. The display textbox piece is working. I have searched the web and have come up with the following code. However it is not working, Please see the code below, I have broken it up into...
1
2243
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 anything and just started picking up things. I am trying to figure out how to make it that if I select "Other" from either one of my drop downs that it makes the "Comment" text box mandatory. One of my...
18
2108
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 property to an empty string ("") that sets the SelectedIndex to -1. Do you have any suggestion for getting around this problem?
0
7767
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
0
7684
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8006
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8196
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8058
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5579
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5288
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3729
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
1035
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.