Example of having MasterPage Select Different widgets.

Topics: Themes
Nov 26, 2011 at 1:31 PM

Hello All,

Found a work around for now for the MasterPage I am loading it up in the site.master itself and not from the

codebehind file.

So far it works.

To see it live check out this website:

http://programmingsolution.net

Notice the differences of the widgets on different pages,posts, and etc.

Sample of Actual Code:

site.master

<%var posturl = Request.Url.ToString(); %>
<%var pageurl = Request.Url.ToString(); %>

<% if (posturl.Contains("/post"))
   { %>

<blog:WidgetZone ID="WidgetZone4" runat="server" ZoneName="Post_Seo1" Visible="true" />

  <% } %>


<% if (pageurl.Contains("/default.aspx"))
   { %>
<blog:WidgetZone ID="WidgetZone2" runat="server" ZoneName="Main_Seo1" Visible="true" />

  <% } %>

  <% if (pageurl.Contains("/page"))
   { %>
<blog:WidgetZone ID="WidgetZone1" runat="server" ZoneName="Page_Seo1" Visible="true" />


  <% } %>

  <% if (pageurl.Contains("/archive.aspx"))
   { %>
<blog:WidgetZone ID="WidgetZone3" runat="server" ZoneName="Archive_Seo1" Visible="true" />

  <% } %>

  <% if (pageurl.Contains("/contact.aspx"))
   { %>
<blog:WidgetZone ID="WidgetZone5" runat="server" ZoneName="Contact_Seo1" Visible="true" />

  <% } %>



  <% if (pageurl.Contains("/search"))
   { %>
<blog:WidgetZone ID="WidgetZone6" runat="server" ZoneName="Search_Seo1" Visible="true" />

  <% } %>

I know this isn't the "proper" way to do it. Should be from the codebehind file site.master.cs

but, this will do for now till I can figure out how to get it from the code behind to work.

Please test out this website and tell me if there are any problems with the widgets or any of the pages.

Thanks,

Brian Davis