Placing ASP.NET Directives in Layout Pages

You can place ASP.NET directives in HTML layout page files by inserting @Register directives at the very beginning of the file.  The @Register directives can occur anywhere in layout page files as long as they are placed before the first use of a tag prefix, i.e., they must precede the <HTML> tag in the file, before the first use of a tag prefix.  This allows you to freely mix ASP.NET controls in layout pages by following this simple rule.

For example, you may have an existing web page header and footer, which were developed using Visual Studio .NET as web user controls.  By way of example, insert the following into the layout page file before the <HTML> tag:

<%@ Register TagPrefix="MyControl" TagName="Header" Src="/MyApp/Shared/Header.ascx" %>

 

<%@ Register TagPrefix="MyControl TagName="Footer" Src="/MyApp/Shared/Footer.ascx" %>

Where the header to be inserted is:

<MyControl:Header

     id="Header"

     runat="server">

</MyControl:Header>

and the footer to be inserted is:

<MyControl:Footer

     id="Footer"

     runat="server">

</MyControl:Footer>

Registering custom controls created with Iron Speed Designer

You don’t have to register any controls created by Iron Speed Designer in pages also created by Iron Speed Designer; Iron Speed Designer does this for you automatically.  However, you may wish to use custom controls created by Iron Speed Designer on pages that were not created by Iron Speed Designer, such as hand-created pages on your website or another application not created by Iron Speed Designer.

To use controls generated by Iron Speed Designer in other web pages, you must register them properly on those ASPX web pages.  Here is an example of a control registration directive:

<%@ Register Tagprefix="MyApp4" TagName="Button" Src="../Shared/Button.ascx" %>

This is how the control should be used within the ASPX page.

<MyApp4:Button runat="server" id="OrdersSearchButton" Button-CausesValidation="False" Button-CommandName="Search" Button-Consumers="OrdersSearchArea" Button-Text="Go">

See Also

Customizing Web Page Layout and Style

Using and Modifying Style Sheets

Using Frames in Layout Pages

Placing ASP.NET Directives in Layout Pages

Adding Site-Wide HTML Tags

Automatically Refresh Page on Periodic Basis

Capturing the Enter Key in Layout Pages