Ver Mensaje Individual
  #4 (permalink)  
Antiguo 24/05/2004, 08:49
Avatar de RootK
RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 23 años
Puntos: 50
Cita:
Es indiferente, tanto para app web como app win.
OK.. por ejemplo en una web app, creas tus controles dentro del evento page_init y despues creas un método y lo asocias a esos controles...

Por ejemplo.. supongamos que creo 2 textbox y los deseo asociar al evento TextChanged... lo haría así:

Los declaro:

Cita:
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
Y en el init:

Cita:
Private Sub Page_Init (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
' Create dynamic controls here.
TextBox1 = New TextBox()
TextBox1.ID = "TextBox1"
TextBox1.AutoPostBack = True
Me.Controls.Add(TextBox1)

TextBox2 = New TextBox()
TextBox2.ID = "TextBox2"
Me.Controls.Add(TextBox2)

End Sub
Creo un método para asociarlos al mismo:

Cita:
Private Sub TextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged
Dim txtBoxSender As TextBox
Dim strTextBoxID As String

txtBoxSender = CType(sender, TextBox)
strTextBoxID = txtBoxSender.ID

Select Case strTextBoxID
Case "TextBox1"
Response.Write("TextBox1 text ha cambiado")

Case "TextBox2"
Response.Write("TextBox2 text Ha cambiado")
End Select
End Sub
Espero que ésto te sirva...o sea lo que buscas..

Saludos