Can an ASP.Net page implement an interface without using a codebehind page?

Tre*_*ent 2 .net c# vb.net asp.net

I have an ASP.Net page that needs to implement an interface class I've created, but since the code in this page is inline, there's no class declaration, and therefore no place to put the "Implements IMyInterface" line. I also tried using the @interface page directive but it appears this only works for built in .Net framework classes.

Are there any options other than using a codebehind page just to edit the class declaration line?

Joe*_*Joe 5

您可以使用Implements指令执行此操作:

<%@ Implements Interface="MyNamespace.IMyInterface"  %>
Run Code Online (Sandbox Code Playgroud)