2nd attempt - post back event in server control

J

Jon Paal

my code is not getting successful result.

how do I get the server control to recognize a button click event ??


========code=============

Public Class MyButton
Inherits System.Web.UI.Page
Implements IPostBackEventHandler


Public Response As HttpResponse = HttpContext.Current.Response


' Defines the Click event.
'-----------------------------
Public Event Click As EventHandler

' OnClick dispatches the event to delegates that
' are registered with the Click event.
' Controls that derive from MyButton can handle the
' Click event by overriding OnClick
' instead of attaching a delegate. The event data
' is passed as an argument to this method.
'-----------------------------------------------
Protected Overridable Sub OnClick(e As EventArgs)
RaiseEvent Click(Me, e)
End Sub

' Method of IPostBackEventHandler that raises change events.
'-----------------------------------------------------------
Public Sub RaisePostBackEvent(eventArgument As String)
Implements PostBackEventHandler.RaisePostBackEvent
OnClick(EventArgs.Empty)
System.Web.UI.Page.ClientScript.RegisterStartupScript(Me.GetType(), "MyScript", _
"function AlertHello() { alert('Hello'); }", True)
End Sub 'RaisePostBackEvent

Public Sub New()
Response.Write("<INPUT TYPE = submit name = " & Me.UniqueID & " Value = 'Click Me' />")
End Sub


End Class
 

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

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top