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

A

Anand Sagar

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
 
A

avnrao

You need to set AutoPostBack event of the textbox to true.

t1.AutoPostBack = true;

Av.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top