asp.net.ph

Skip Navigation Links

@ Implements

ASP.NET Syntax   ASP.NET Page Syntax   Page Directives


Indicates that the current page implements the specified .NET Framework interface.

<%@ Implements interface = "ValidInterfaceName" %>

Attributes


interface The interface to be implemented on the page.

Remarks

When you implement an interface in a Web Forms page, you can declare its events, methods, and properties between opening and closing tags of a <script> element in a code declaration block. You cannot use this directive to implement an interface in a code-behind file.

Syntax Example

The below code snippet demonstrates a user control that includes an @ Implements directive to access to the properties and methods of the IPostBackEventHandler interface. To use this sample, include it in a .ascx file, then declare the user control in a Web Forms page ( an .aspx file ). For more information on how to include a user control in a Web Forms page, see the following topics: @ Register, Custom Server Control Syntax, and Including a User Control in a Web Forms Page.

<%@ Implements Interface = "System.Web.UI.IPostBackEventHandler" %>
<script language="C#" runat="server">

   // defines Text property and Click event.
   public String Text;
   public event EventHandler Click;

   // evaluates data binding expressions when page is loaded.
   void Page_Load ( Object sender, EventArgs e ) {
      this.DataBind ( );
   }
   // implementation of the event
   public virtual void RaisePostBackEvent ( string eventArgument ) {
      onClick ( new EventArgs ( ) );
   }

   protected virtual void onClick ( EventArgs e ) {
      if ( Click!= null ) {
         Click ( this,e );
      }
   }
</script>

<a href=<%# String.Format ( "javascript:{0}",
   Page.GetPostBackEventReference ( this ) ) %>>
   <asp:Label id=l1 Text='<%# Text%>’ runat="server" />

</a>
  C# VB

See Also

Web Forms Code Model



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note