I have quite simple site structure with one mastepage and a bunch of pages. The mastepage is quite advanced though and I need from the page be able to control certain aspects of the Masterpage.
I want to be able to enter these directive in the aspx file to not clutter the code behind files.
My idea was to create different "directive" user controls such as SeoDirective:
using System;
public partial class includes_SeoDirective : System.Web.UI.UserControl
{
public string Title { get; set; }
public string MetaDescription { get; set; }
public string MetaKeywords { get; set; }
}
I include this directive in those pages that need to override the default mastepage settings.
<offerta:SeoDirective runat="server" Title="About Us" MetaDescription="Helloworld"/>
In my masterpage I look if there's any directives:
includes_SeoDirective seo = (includes_SeoDirective) ContentPlaceHolder1.Controls.Children().FirstOrDefault(e => e is includes_SeoDirective);
(Children() is an extension so I can work with Linq on a ControlCollection)
Now to my question: I'm not to happy about this solution might be a bit bloated?
I'm looking for alternative solutions where I can created these tags in the aspx file.
I've looked at the trick where I extend the Page, but that requiries we to modify the VS configs for the project to compile, so I dropped that solutions.