[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.buildingcontrols

2nd attempt - post back event in server control

Jon Paal [MSMD]

9/24/2006 4:15:00 PM

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


2 Answers

MasterGaurav \(www.edujini-labs.com\)

9/30/2006 2:23:00 PM

0

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

???

I think it should be:

Public Class MyButton
Inherits System.Web.UI.Contro
'or Inherits System.Web.UI.WebControls.WebControl
Implements IPostBackEventHandler...



--
Happy Hacking,
Gaurav Vaish | http://www.master...
http://www.edujini...
http://articles.edujinionline.com/w...
-------------------


Stavs

6/13/2010 12:02:00 PM

0

On Jun 12, 7:06 pm, Jay <playmorepinb...@verizon.net> wrote:
> Edd...
>
> Hope you cleared this with your wife first.

LOL and a bump.