I'm working on a somewhat advanced custom framework for some websites I'm developing at work, and I'm implementing a small plugin system for it. I want to register the plugins somehow in the ASPX file so I can then hook into the different page events (Load, PreRender, etc.) after calling them in sequence in my Page_Init function, for example. I'll jump straight to the code so you see what I want to do:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Plugin TypeName="MyFramework.Plugin.Core" Arg1="arg1" Arg2="arg2" %>
<%@ Plugin TypeName="MyFramework.Plugin.MainMenu" Arg1="arg1" Arg2="arg2" %>
<%@ Plugin TypeName="MyFramework.Plugin.IE6Hacks" Arg1="arg1" Arg2="arg2" %>
<%@ Plugin TypeName="MyFramework.Plugin.Footer2015" Arg1="arg1" Arg2="arg2" %>
<%@ Plugin TypeName="MyFramework.Plugin.SortableGridViews" Arg1="arg1" Arg2="arg2" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>blah</title>
</head>
<body>
<form id="form1" runat="server"> Blah... </form>
</body>
</html>
See those <% Plugin %>
directives? they don't exist in ASP.NET but I want to create them. I can't find anything on google regarding this stuff. Is it possible to create a custom one?
My idea is that once they're "registered" with those directives, I can loop through all of them (either stored in an array everytime the directive is hit, or in the Page_Init event) and act accordingly.
Another idea I had was to use code blocks instead:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<% RegisterPlugin("MyFramework.Plugin.Core"); %>
<% RegisterPlugin("MyFramework.Plugin.MainMenu"); %>
<% RegisterPlugin("MyFramework.Plugin.IE6Hacks"); %>
<% RegisterPlugin("MyFramework.Plugin.Footer2015"); %>
<% RegisterPlugin("MyFramework.Plugin.SortableGridViews"); %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>blah</title>
</head>
<body>
<form id="form1" runat="server"> Blah... </form>
</body>
</html>
BUT the functions get called after all the page events instead of running before them (or at least before Page_Load) leaving me with no way of detecting if I have plugins registered in order to act accordingly in my base page's Page_Load events and such.
Any ideas are really appreciated :). Thanks in advance!