Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem attaching multiple buttons to a 1 event handler....
Message
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Problem attaching multiple buttons to a 1 event handler....
Miscellaneous
Thread ID:
00685751
Message ID:
00685751
Views:
71
I try to attach a lot of button to a same event. I need
this becuase the buttons have the A-Z 0-9 chars for a
index, and i only need to know which button is press, so
i build a event to fire the query. I follow the help
instrucctions but nothing work! (no error is reported)

This is the code:

Namespace GyGWebControls
{0}:TBarraConsultas>")> Public Class TBarraConsultas
Inherits System.Web.UI.WebControls.WebControl
Implements IPostBackEventHandler

Public Event OnButtonClick(ByVal lcChar As Char)

' Method of IPostBackEventHandler that raises
change events.
Public Sub RaisePostBackEvent(ByVal eventArgument
As String) Implements
IPostBackEventHandler.RaisePostBackEvent
Dim i As Integer = 2
i = i + 1 ' I put it only for put a breakpoint
End Sub 'RaisePostBackEvent

Protected Overrides Sub CreateChildControls()
' Crear los controles de la A-Z y del 0-9
'Armar las letras (son los caracteres del 65-
90)
CrearBotones(65, 90)
'Armar los números (son los caracteres del 48-
57)
CrearBotones(48, 57)
End Sub

' Crea cada botones
Protected Sub CrearBotones(ByVal NumChar1 As
Integer, ByVal NumChar2 As Integer)
Dim i As Integer
Dim oBoton As WebControls.Button

For i = NumChar1 To NumChar2
oBoton = New WebControls.Button()
' Convierte el numero que representa el
caracter en la tabla ASCII
oBoton.Text = ChrW(i)
' Informar el caracter que se desea buscar
AddHandler oBoton.Click, AddressOf
Me.ButtonClick
'oBoton.Click += Me.ButtonClick

oBoton.CommandArgument = ChrW(i)
oBoton.Visible = True
Controls.Add(oBoton)
Next
End Sub

Public Sub ButtonClick(ByVal sender As Object,
ByVal e As System.EventArgs)
' Informar cual se presiono
RaiseEvent OnButtonClick(CType(sender,
WebControls.Button).CommandArgument)
End Sub

Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
'Renderizar los controles
If HasControls() Then
RenderChildren(output)
End If
End Sub
End Class
End Namespace
.
The Life is Beautiful!

Programmer in
Delphi, VS.NET
MCP
Next
Reply
Map
View

Click here to load this message in the networking platform