Ver Mensaje Individual
  #4 (permalink)  
Antiguo 20/01/2009, 05:07
Javichechu
 
Fecha de Ingreso: junio-2007
Mensajes: 327
Antigüedad: 17 años, 8 meses
Puntos: 0
Respuesta: Conseguir que un control Web propio reaccione al evento Click

Con éste código funciona perféctamente

Código:
Imports System
Imports System.Web.UI
Imports System.Collections
Imports System.Collections.Specialized

Namespace CustomControls

    <System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> Public Class MyButton
        Inherits Control
        Implements IPostBackEventHandler

        ' Define the Click event.
        Public Event Click As EventHandler


        ' Invoke delegates registered with the Click event.
        Protected Overridable Sub OnClick(ByVal e As EventArgs)
            RaiseEvent Click(Me, e)
        End Sub


        ' Define the method of IPostBackEventHandler that raises change events.
        Public Sub RaisePostBackEvent(ByVal eventArgument As String) _
        Implements IPostBackEventHandler.RaisePostBackEvent

            OnClick(New EventArgs())
        End Sub


        Protected Overrides Sub Render(ByVal output As HtmlTextWriter)
            output.Write("<INPUT TYPE = submit name = " & Me.UniqueID & _
                " Value = 'Click Me' />")
        End Sub

    End Class
End Namespace
La cosa está es que en el Render, si en lugar de pintar un input de tipo submit, pinto una tabla (El botón es una tabla con varias celdas) pues ya no funciona el click. De alguna forma debo indicarle el evento click a la tabla, supongo que será con eso que me pones arriba, pero si me puedes especificar un poco más mejor.

Gracias