eugeneK
eugeneK

Reputation: 11116

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 strings 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

Upvotes: 1

Views: 112

Answers (2)

Krunal
Krunal

Reputation: 3541

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.

Upvotes: 2

Jan Remunda
Jan Remunda

Reputation: 7930

you must convert type of Master property in nested page:

((MyMasterPage)this.Master).lblMessage.Text = "Hi.";

Upvotes: 1

Related Questions