473,396 Members | 2,011 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.

textbox changed event

hi,

I'm trying to update a label with the text in a textbox as the user
types in the information.

something like this is not working:

Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs)

label1.text = me.textbox1.text

End Sub

I want to update the label for every key stroke.

Nov 21 '06 #1
7 5841
Using JavaScript for that would be better than postbacking on every letter.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
<jo***********@gmail.comwrote in message
news:11*********************@k70g2000cwa.googlegro ups.com...
hi,

I'm trying to update a label with the text in a textbox as the user
types in the information.

something like this is not working:

Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs)

label1.text = me.textbox1.text

End Sub

I want to update the label for every key stroke.

Nov 21 '06 #2
I suggest you do this from the client side .. it is much more
efficient in terms of resources and certainly much faster.

On page load add this code:

if(!Page.IsPostBack)
TextBox1.Attributes.Add("onChange","label1.value=t extbox1.value");
On 21 Nov 2006 12:04:38 -0800, jo***********@gmail.com wrote:
>hi,

I'm trying to update a label with the text in a textbox as the user
types in the information.

something like this is not working:

Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs)

label1.text = me.textbox1.text

End Sub

I want to update the label for every key stroke.
--

Bits.Bytes.
http://bytes.thinkersroom.com
Nov 21 '06 #3
i'm using the new ajax extensions to update the events. resources are
not a problem. this is being used for a specific purpose. is it
possible to change the label with each keystroke?
this is being done in visual web developer 2005.

Nov 21 '06 #4
The problem, though, is that the textChanged event only fires once the focus
is lost from the TextBox.

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com

<jo***********@gmail.comwrote in message
news:11**********************@j44g2000cwa.googlegr oups.com...
i'm using the new ajax extensions to update the events. resources are
not a problem. this is being used for a specific purpose. is it
possible to change the label with each keystroke?
this is being done in visual web developer 2005.

Nov 21 '06 #5
yes, now you understand the problem i'm running into. is there an easy
way to change this?

Nov 21 '06 #6
I'm not sure if that is possible using the current implementation of
asp.net.

The textchanged event fires when the text as a whole changes, not when
a character in the textbox changes.

You might have to do a little more work to achieve what you're lookng
for.

I suspect you might have to write a client side javascript function to
handle the keydown event and in that function submit the form.

Still, the latency of this approach is likely to be an issue
On 21 Nov 2006 12:20:48 -0800, jo***********@gmail.com wrote:
>i'm using the new ajax extensions to update the events. resources are
not a problem. this is being used for a specific purpose. is it
possible to change the label with each keystroke?
this is being done in visual web developer 2005.
--

Bits.Bytes.
http://bytes.thinkersroom.com
Nov 21 '06 #7
hi,
call a javascript method with page registerstartupscript method
with the object which you want to focus() at startup.

Page.RegisterStartupScript("focus","<script>SetFoc us('"+txtbox1.ClientID+"');");

function SetFocus(obj)
{
document.getElementById(obj).focus();
}

Asp.net isnt only a server side programing. you should have to use
javascript for developing web apps.

--
Esref DURNA
Turkish Cypriot Software Engineer
Asp.Net , C#
"jo***********@gmail.com" wrote:
yes, now you understand the problem i'm running into. is there an easy
way to change this?

Nov 21 '06 #8

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

Similar topics

6
by: Ahmad A. Rahman | last post by:
Hi Wizards, I have a data set and I bound it to 2 combobox (say ComboBox1 and ComboBox2) using ComboBox1.DataSource = MyDataSet and it worked well. That also means that when I select an item...
2
by: Alpha | last post by:
Hi, I have a window based program. One of the form has several textboxes and a datagrid. The textboxes are bind to the same dataset table as the datagrid and the text changes to reflect different...
2
by: NewToDotNet | last post by:
Hi, I am very new to ASP.NET and web programming in general. I have one issue. I have a Datagrid object with Edit template. In one Datagrid row, I have 1 DropdownList, 1 textbox and 1 readonly...
9
by: Jerry | last post by:
In limiting textbox input to 500 characters I would like to include a dynamic count of characters input while the user is typing into a textbox. This would obviously be a client side control,...
4
by: MattB | last post by:
Hi. I'm working on an intranet application that requires a user to input information about themselves. I have a user control with a couple of textboxes that I want the user to enter their weight...
11
by: Joe | last post by:
Hello All, I have an ASP.NET page with one Textbox (SearchTextBox) and one ImageButton (SearchButton) server controls. The user can type search text in SearchTextBox and click SearchButton and...
6
by: JohnR | last post by:
I have a table with 1 row which is used to hold some application wide items (one item per field, hence I only need 1 row). I want to bind one of the fields to a textbox. After setting up the...
4
by: Jason Huang | last post by:
Hi, In my C# Windows form MyForm I have some TextBoxes. In these TextBoxes, we have to detect if the TextChanged event occurs, if there're changes in these TextBoxes, it will ask if we want to...
2
by: jd | last post by:
I have several textboxes in which the end user can enter values. When the user presses the Enter key when in any of the textboxes, or leaves that textbox, I want a routine to run (mathematical...
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
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
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.