473,396 Members | 1,859 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.

How to raise TextChange event for textbox created at run-time.

My program requirement is to create 2 textboxes at run time. When the cursor
leaves the first textbox, (i guess the TextChange event) I want something to
occur (post data into database)

Problem is that in Which event of the Webform do I create the run-time
textboxes ?

Also, how can I raise the events ? Please check my code, give suggetions.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

Dim t1 As New TextBox()

Dim t2 As New TextBox()

t1.Text = "sagar"

t1.ID = "t1"

AddHandler t1.TextChanged, AddressOf DoThis

Panel1.Controls.Add(t1)

t2.Text = "Tres"

t2.ID = "t2"

Panel1.Controls.Add(t2)

End Sub

Protected Sub DoThis(ByVal sender As Object, ByVal e As EventArgs)
Response.Write("feeling great")
End Sub
Thanks,
Anand Sagar
Nov 18 '05 #1
2 3095
You need to set AutoPostBack event of the textbox to true.

t1.AutoPostBack = true;

Av.

"Anand Sagar" <ba*****@vermar.com> wrote in message
news:O7**************@TK2MSFTNGP12.phx.gbl...
My program requirement is to create 2 textboxes at run time. When the
cursor
leaves the first textbox, (i guess the TextChange event) I want something
to
occur (post data into database)

Problem is that in Which event of the Webform do I create the run-time
textboxes ?

Also, how can I raise the events ? Please check my code, give suggetions.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

Dim t1 As New TextBox()

Dim t2 As New TextBox()

t1.Text = "sagar"

t1.ID = "t1"

AddHandler t1.TextChanged, AddressOf DoThis

Panel1.Controls.Add(t1)

t2.Text = "Tres"

t2.ID = "t2"

Panel1.Controls.Add(t2)

End Sub

Protected Sub DoThis(ByVal sender As Object, ByVal e As EventArgs)
Response.Write("feeling great")
End Sub
Thanks,
Anand Sagar

Nov 18 '05 #2
Thanks Rao, It works now.

:-)
Anand Sagar.

"avnrao" <av*@newsgroups.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
You need to set AutoPostBack event of the textbox to true.

t1.AutoPostBack = true;

Av.

"Anand Sagar" <ba*****@vermar.com> wrote in message
news:O7**************@TK2MSFTNGP12.phx.gbl...
My program requirement is to create 2 textboxes at run time. When the
cursor
leaves the first textbox, (i guess the TextChange event) I want something to
occur (post data into database)

Problem is that in Which event of the Webform do I create the run-time
textboxes ?

Also, how can I raise the events ? Please check my code, give suggetions.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

Dim t1 As New TextBox()

Dim t2 As New TextBox()

t1.Text = "sagar"

t1.ID = "t1"

AddHandler t1.TextChanged, AddressOf DoThis

Panel1.Controls.Add(t1)

t2.Text = "Tres"

t2.ID = "t2"

Panel1.Controls.Add(t2)

End Sub

Protected Sub DoThis(ByVal sender As Object, ByVal e As EventArgs)
Response.Write("feeling great")
End Sub
Thanks,
Anand Sagar


Nov 18 '05 #3

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

Similar topics

1
by: Duwayne | last post by:
I am having a lot of trouble with an ascx page that has a textbox that *should fire a textchange event when the text changes. The main aspx page dynamically loads the ascx page and has a image...
5
by: PD | last post by:
The TextChanged event is not being called when I hit the "Enter" key. Yet it does for the "Tab" key. I set a break point in the Page_Load event and the TextChanged event and none of these get...
0
by: sunilthk | last post by:
Hi All, I want to know how the TextBox control knows that it's data has been changed, since it is able to detect changes and fires TextChange event if the data in the TextBox has been changed. I...
0
by: nil | last post by:
Hi everyone... can anyone tell me how to fire textchange event of textbox that is in datagrid...as on the basis of that i wana fetch data from the database.if you can provide code snippet or any...
2
by: nil | last post by:
Hi everyone... can anyone tell me how to fire textchange event of textbox that is in datagrid...as on the basis of that i wana fetch data from the database.if you can provide code snippet or any...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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.