how can access public properties of MasterPage from external Class?
<p>Why i can't access MasterPage's public property (MessagePlaceholder) from other Class (Errors) ?</p>

<p>Error compiler gives me is "Error 1 The type or namespace name 'MyMasterPage' could not be found (are you missing a using directive or an assembly reference?)"</p>

<p>my master page code behind</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class MyMasterPage : System.Web.UI.MasterPage
{
    public string MessagePlaceholder
    {
        get { return messagePlaceholder.InnerHtml; }
        set { messagePlaceholder.InnerHtml = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            messagePlaceholder.InnerHtml = Errors.getMessage();
        }
    }
}
</code></pre>

<p>my Errors Class</p>

<pre><code> public static string getMessage()
    {
        HttpContext c = HttpContext.Current;
        string messageType = "";
        if (c.Session["errorMessage"] != null)
        {
            messageType = "errorMessage";
        }
        else if (c.Session["successMessage"] != null)
        {
            messageType = "successMessage";
        }

        if (!string.IsNullOrEmpty(messageType))
        {
            StringBuilder userMessageSb = new StringBuilder();
            userMessageSb.Append(string.Format("&lt;div id=\"{0}\" title=\"{1}\"&gt;{2}&lt;/div&gt;", messageType, messageType.Replace("Message",string.Empty), c.Session[messageType]));

            // fix so message will not re-appear
            c.Session.Remove(messageType);

            messageType = userMessageSb.ToString();
        }
        return messageType;
    }

    public static void setSuccess(string successMessage, bool isRedirect)
    {
        HttpContext.Current.Session["successMessage"] = successMessage;
    }

    public static void setError(string errorMessage, bool isRedirect)
    {
        HttpContext.Current.Session["errorMessage"] = errorMessage;

        if (!isRedirect)
        {
            ((HttpContext.Current.CurrentHandler as System.Web.UI.Page).Master as MyMasterPage).MessagePlaceholder = getMessage();
        }
    }
</code></pre>

<p>this is how i set error</p>

<pre><code>    if (true)
    {
        Errors.setError("this is an error demo", false);
        return;
    }
</code></pre>

<p>or with redirect after error</p>

<pre><code>   if (true)
    {
        Errors.setError("yet another error", true);
        Response.Redirect("~/error.aspx");
    }
</code></pre>
