ASP.NET User messages on MasterPages
i have an admin master page where i want to place a label which i can control with two functions (setErrorMessage and setSuccessMessage) both functions assign strin开发者_StackOverflow中文版gs to label's text property and change CssClass property according to function type.
I want to use these functions from nested pages while the control remains centralized on master page so i can return to form in case of error so user could edit wrong input.
How would you suggest me to do that ? either VB or C#
thanks
You can use below in .aspx
<%@ MasterType VirtualPath="~/MasterPages/Default.master" %>
and below in your code behind,
this.Master.yourMethod
this.Master.yourProperty
to access your controls in child page.
you must convert type of Master property in nested page:
((MyMasterPage)this.Master).lblMessage.Text = "Hi.";
精彩评论