Access Master Page public method from user control/class/page

I am to access a method on my master page. I have an error label which I want to update based on error messages I get from my site.

public string ErrorText
    get { return this.infoLabel.Text; }
    set { this.infoLabel.Text = value; }

How can I access this from my user control or classes that I set up?


Page should contain next markup:

<%@ MasterType VirtualPath="~/Site.master" %>

then Page.Master will have not a type of MasterPage but your master page's type, i.e.:

public partial class MySiteMaster : MasterPage
    public string ErrorText { get; set; }

Page code-behind:

this.Master.ErrorText = ...;

Another way:

public interface IMyMasterPage
    string ErrorText { get; set; }

(put it to App_Code or better - into class library)

public partial class MySiteMaster : MasterPage, IMyMasterPage { }


((IMyMasterPage )this.Page.Master).ErrorText = ...;

To access the masterpage:


then you might need to cast to the actual type of the master page so that you could get the ErrorText property or make your master page implement an interface containing this property.

Need Your Help

Restricting a portion of code through an association

ruby-on-rails ruby model associations

I have built a ruby on rails app that lets users track their workouts. User has_many workouts. In addition, a User can create a box (gym) if they are a gym owner. The purpose is to filter activity of

Result of a select case statement for multiplication in SQL Server

sql sql-server

Can anyone tell me how to use the result of a select case statement for multiplication?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.