Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
Previous Versions
.NET Framework 1.1
.NET Framework
Reference
System.Web.UI

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2003/.NET Framework 1.1

Other versions are also available for the following:
.NET Framework Class Library
IPostBackEventHandler Interface

Defines the method ASP.NET server controls must implement to handle post back events.

For a list of all members of this type, see IPostBackEventHandler Members.

[Visual Basic]
Public Interface IPostBackEventHandler
[C#]
public interface IPostBackEventHandler
[C++]
public __gc __interface IPostBackEventHandler
[JScript]
public interface IPostBackEventHandler

Classes that Implement IPostBackEventHandler

Class Description
Button Displays a push button control on the Web page.
Calendar Displays a single month calendar that allows the user to select dates and move to the next or previous month.
HtmlAnchor Allows programmatic access to the HTML <a> tag on the server.
HtmlButton Allows programmatic access to the HTML <button> tag on the server.
HtmlInputButton Allows programmatic access to the HTML <input type= button>, <input type= submit>, and <input type= reset> elements on the server.
HtmlInputImage Allows programmatic access to the HTML <input type= image> element on the server.
ImageButton A control that displays an image and responds to mouse clicks on the image.
LinkButton Displays a hyperlink style button control on a Web page.

Remarks

To create a server control that captures form submit information from the browser, you must implement this interface. For more information on how to use this interface, see Capturing Postback Events.

Example

[Visual Basic, C#, C++] The following example defines a custom button server control that causes post back, captures the post back event using the RaisePostBackEvent method, and raises a Click event on the server.

[Visual Basic] 
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(e As EventArgs)            
            RaiseEvent Click(Me, e)
        End Sub
        
        
        ' Define the method of IPostBackEventHandler that raises change events.
        Public Sub RaisePostBackEvent(eventArgument As String) _
        Implements IPostBackEventHandler.RaisePostBackEvent
        
            OnClick(New EventArgs())
        End Sub       
        
        
        Protected Overrides Sub Render(output As HtmlTextWriter)
            output.Write("<INPUT TYPE = submit name = " & Me.UniqueID & _
                " Value = 'Click Me' />")
        End Sub
        
    End Class
End Namespace


[C#] 
using System;
using System.Web.UI;
using System.Collections;
using System.Collections.Specialized;

namespace CustomControls {

   [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]   
   public class MyButton: Control, IPostBackEventHandler {
      
      // Defines the Click event.
      public event EventHandler Click;
      
      //Invoke delegates registered with the Click event.
      protected virtual void OnClick(EventArgs e) {
         
         if (Click != null) {
            Click(this, e);
         }   
      }
      
      
      // Define the method of IPostBackEventHandler that raises change events.
      public void RaisePostBackEvent(string eventArgument){
         
         OnClick(new EventArgs());
      }
      
      
      protected override void Render(HtmlTextWriter output) {
         output.Write("<INPUT TYPE = submit name = " + this.UniqueID + 
            " Value = 'Click Me' />");   
      }
   }    
}
   

[C++] 
#using <mscorlib.dll>
#using <System.Web.dll>
#using <System.dll>
using namespace System;
using namespace System::Web::UI;
using namespace System::Collections;
using namespace System::Collections::Specialized;

[System::Security::Permissions::PermissionSet(System::Security::Permissions::SecurityAction::Demand, Name=S"FullTrust")]   
public __gc class MyButton: public Control, public IPostBackEventHandler {

   // Defines the Click event.
public:
   __event EventHandler* Click;

   //Invoke delegates registered with the Click event.
protected:
   virtual void OnClick(EventArgs* e) {

      if (Click != 0) {
         Click(this, e);
      }   
   }


   // Define the method of IPostBackEventHandler that raises change events.
public:
   void RaisePostBackEvent(String* eventArgument){

      OnClick(new EventArgs());
   }


protected:
   void Render(HtmlTextWriter* output) {
      output->Write(S"<INPUT TYPE = submit name = {0} Value = 'Click Me' />", this->UniqueID);   
   }
};    

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Web.UI

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

Assembly: System.Web (in System.Web.dll)

See Also

IPostBackEventHandler Members | System.Web.UI Namespace | Capturing Postback Events

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker