473,322 Members | 1,703 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,322 software developers and data experts.

Textbox with OnTextChanged Event

Hello:

I create a textbox control programatically something like this:

Dim td As New TableCell()
Dim txtbox As New TextBox()
txtbox.ID = "my_textbox"
td.Controls.Add(txtbox)

Now I want to programatically associate a "OnTextChanged" event to this
textbox.

How can I do this?

When I view the page source, the ID of the textbox control is something like
"ctl00$my_textbox". So the textbox ID actually gets changed.

Can anyone point me to an example or a link that explains how to do this?

TIA.

- Paul
Jun 14 '06 #1
2 2171
Are you trying to execute a javascript event handler client side when the
text changes or do you want a post back that will execute server side code?

"Paul" wrote:
Hello:

I create a textbox control programatically something like this:

Dim td As New TableCell()
Dim txtbox As New TextBox()
txtbox.ID = "my_textbox"
td.Controls.Add(txtbox)

Now I want to programatically associate a "OnTextChanged" event to this
textbox.

How can I do this?

When I view the page source, the ID of the textbox control is something like
"ctl00$my_textbox". So the textbox ID actually gets changed.

Can anyone point me to an example or a link that explains how to do this?

TIA.

- Paul

Jun 14 '06 #2
Dim txtbox As New TextBox
txtbox.ID = "my_textbox"

AddHandler txtbox.TextChanged, AddressOf <methodname>

note methodname is the function or sub which will handle the textchange event

Private Sub txtbox_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs)
.....code here
End Sub
"Paul" wrote:
Hello:

I create a textbox control programatically something like this:

Dim td As New TableCell()
Dim txtbox As New TextBox()
txtbox.ID = "my_textbox"
td.Controls.Add(txtbox)

Now I want to programatically associate a "OnTextChanged" event to this
textbox.

How can I do this?

When I view the page source, the ID of the textbox control is something like
"ctl00$my_textbox". So the textbox ID actually gets changed.

Can anyone point me to an example or a link that explains how to do this?

TIA.

- Paul

Jun 14 '06 #3

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

Similar topics

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...
5
by: Vi | last post by:
Hello, I want to be able to reload a DropDownList when a TextBox changes its value. So I set the AutopostBack property of the TextBox to true and in the code behind I do something like: ...
2
by: tshad | last post by:
Is there a way to raise an event when a user exits a textbox? I tried OnTextChanged and that doesn't seem to do it. <asp:textbox id="email" TextMode="SingleLine" OnTextChanged="checkRecords"...
3
by: Sandy | last post by:
Hello - I have a page that runs a stored procedure checking for the existence of a name in a database. If it exists, lblMessage returns text indicating same. When a user goes back and clears...
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...
1
by: OceanBreeze | last post by:
I am using ASP 2.0 and C# I have a TextBox control in .aspx file. <asp:TextBox ID="CityTxt" runat="server"></asp:TextBox> When I click on that text box, I want to trigger onClick event. ...
2
by: | last post by:
I have a gridview with a textbox in an ItemTemplate, as below. The OnTextChanged event fires okay but how do I pass a parameter to it, I get an error when I try "OnTextChanged(""SomeData"")". I...
1
by: madhanmss | last post by:
Hi, i have two textboxes to enter the start and end dates. I am using javascript calendar to populate these text boxes. Based on the chosen date values, i need to filter a treeview control. ...
9
by: David C | last post by:
I have an asp.net page that contains a FormView with several controls bound to a SqlDataSource. One of the controls is a TextBox bound to a date column. I have the following additional properties...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.