473,396 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Selecting textbox contents

Hi everyone

Is it possible to select the contents in an aspnet textbox? (Like the old
textbox selectstart and so on properties)

Thanx in advance
Nov 18 '05 #1
3 1380
Hi, Strange Cat,

The TextBox is rendered to the client (the html that is sent to the browser)
as <input type="text"...>, <input type="password"...> or
<textarea></textarea> HTML element. So, you can set whatever client-side
properties, events, styles, etc. apply to these elements to your TextBox.

To access from the server-side (the code-behind) some specific event or
property of the HTML element that do not have corresponding properties of
the System.Web.UI.WebControls.TextBox class you should use the Attributes
property of this class.

http://msdn.microsoft.com/library/en...butestopic.asp

i.e. to assign some javascript function that will handle the onselectstart
event:

[C#]
textbox1.Attributes["onselectstart"] = "javascript:DoSomething();";
[VB.NET]
textbox1.Attributes("onselectstart") = "javascript:DoSomething();"

Hope this helps
Martin
"Strange Cat" <st*****@cat.com> wrote in message
news:Ou********************@news4.tin.it...
Hi everyone

Is it possible to select the contents in an aspnet textbox? (Like the old
textbox selectstart and so on properties)

Thanx in advance

Nov 18 '05 #2
Thanx for answering Martin!

I dont think what you suggested would do what I need, tho:

Looks like your idea would fire an event when the user selects stuff inside
the textbox. What I'd like to do is to programmatically select stuff inside
the textbox (so that if the user types a key, the preexisting chars are
automatically cleared...).

Any idea?

Thanx

ASC
Nov 18 '05 #3
The behavior you are looking for needs to happen on the client side ...
Martin is right, even if he answered for the onselect event ... Whatever
will do your trick will have to be done on the client side (javascript,
DHTML ...)
If you do need to implement on the server side - round trip to the server -
, then you use just what Martin said, and then handle the selection event on
the server side to add the necessary attributes (selectstart, ...etc) and
send back to client ...

"Strange Cat" <st*****@cat.com> wrote in message
news:Ou********************@news4.tin.it...
Hi everyone

Is it possible to select the contents in an aspnet textbox? (Like the old
textbox selectstart and so on properties)

Thanx in advance

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Paul | last post by:
How would I convert the contents of a textbox into text files. Say I have a textbox containin the following... 13-02-00 - Paul Oakenfold 06-02-00 - William Orbit 30-01-00 - Laurent Garnier...
3
by: Omar Llanos | last post by:
I have Form1 and Form2 (which is inherited from Form1), and I created a button in Form2 that will fill up a textbox in Form1. What code would do that? I tried the simplest way: //from child...
4
by: melanieab | last post by:
Hi, I need to write something so that when a textbox is entered (this is for a touchscreen), all the text in that textbox is selected (highlighted) and new keystrokes replace the old text. Help!...
0
by: Nick Garner | last post by:
Hello, I would think this would be pretty easy but have been searching for a while and trying all of the printpageeventhandler function things I can think of... I have an app that grabs a set...
42
by: Dooglo | last post by:
I'm new VB and programming all together, but I'm getting he hang of it. My question is; I'm writting a program to figure square feet and yards when the user inputs "Length in feet and inch (...
6
by: Dhananjay | last post by:
hi everyone i have a problem how to save the textbox contents to sql server database. i am getting this contents after conversion from web browser into textbox(multiline) I want to store all the...
2
by: Abubakar | last post by:
Hi, In a normal Windows.Forms.TextBox control, I want to be able to select a text (ie highlight, this is by default possible) and than be able to drag that text through my mouse pointer to another...
2
by: JJ | last post by:
I have a textbox that is used to insert some html code. I want to highlight errors in the code, possibly by selecting the text. Is it possible to highlight/select areas of a textbox...
5
by: Nick | last post by:
Hey there, I'm trying to get a textbox (using ASP.NET / VB.NET) to display XML without freaking out the browser afterwards. Currently I have the textbox displaying the XML fine, but that's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.