Can't access widgetzone from my master page

Topics: ASP.NET 2.0, Business Logic Layer, Controls, Themes
Sep 11, 2011 at 8:59 AM

When I try to use the following code ("WidgetZone.Visible = false;" ) I get the following error: "The name 'WidgetZone' does not exist in the current context"

Here are the name spaces I'm importing:


using System;

 

using System.Web;

 

using System.Web.UI;

using System.Web.UI.HtmlControls;

using BlogEngine.Core;



Nov 24, 2011 at 7:04 AM

Its been a while since working with the widget zone with code behind and can't find the code I was using before.

It worked before in BE 2.0 but not working in BE 2.5 getting error:

 

The name 'WidgetZone' does not exist in the current context"

This is my code behind file.

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using BlogEngine.Core;

public partial class Seo1 : System.Web.UI.MasterPage
{
  protected void Page_Load(object sender, EventArgs e)
  {

      var url = Request.Url.ToString();
      if (url.Contains("/post"))
      {
          WidgetZone.Visible = false;
          

      }

      else


          WidgetZone.ZoneName = "LeftSide_Seo1";
      
      
      if (Security.IsAuthenticated)
		{
            aUser.InnerText = "Welcome " + Page.User.Identity.Name + "!";
			aLogin.InnerText = Resources.labels.logoff;
			aLogin.HRef = Utils.RelativeWebRoot + "Account/login.aspx?logoff";
		}
		else
		{
			aLogin.HRef = Utils.RelativeWebRoot + "Account/login.aspx";
			aLogin.InnerText = Resources.labels.login;
		}
		
		
		
  }

	
  
}


I bet I am missing a namespace just don't remember which one to use :)

Thanks,

Brian Davis

Nov 26, 2011 at 4:09 AM

Here is my current code now:

 

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using BlogEngine.Core;
using App_Code.Controls;

using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;

using System.Web.UI.WebControls;
using System.Xml;


using BlogEngine.Core.DataStore;
using BlogEngine.Core.Providers.CacheProvider;

using Resources;
using System.Web.Hosting;

public partial class Seo1 : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        var url = Request.Url.ToString();
       
        if (url.Contains("/post"))
        {
            WidgetZone.ZoneName.LeftSide_Seo1.Visiable = false;
        }

        else
            WidgetZone.ZoneName = "LeftSide_Seo1";



        if (Security.IsAuthenticated)
        {
            aUser.InnerText = "Welcome " + Page.User.Identity.Name + "!";
            aLogin.InnerText = Resources.labels.logoff;
            aLogin.HRef = Utils.RelativeWebRoot + "Account/login.aspx?logoff";
        }
        else
        {
            aLogin.HRef = Utils.RelativeWebRoot + "Account/login.aspx";
            aLogin.InnerText = Resources.labels.login;
        }

    }

}

Now getting this error:

 

Error    7    An object reference is required for the non-static field, method, or property 'App_Code.Controls.WidgetZone.ZoneName.get'   

C:\Users\thecuddlyhoney\Desktop\vWSeo\WebSite\BackUps\10Nov2011\wwwroot\themes\Seo1\site.master.cs    31    13   

Nov 28, 2011 at 1:35 PM

I still need help with this one :)