tags:

views:

141

answers:

4

I want to change master page some label value from child page.

+4  A: 

Create a property like this in master page:

public string MyText { get {return lbl.Text;} set {lbl.Text = value;}}

Once you do that you can use the same property in content page like:


((MasterPageTypeName)Page.MasterPage ).MyText = "test";

and you are done!

lakhlaniprashant.blogspot.com
perfact i have check it.
AjmeraInfo
+1  A: 

Or you can just add '@mastertype' to the child page .aspx declaratively. This creates a strongly-typed reference to the masterpage.

<%@ MasterType VirtualPath="~/masters/SourcePage.master" %>
SoftwareGeek
A: 

Everything is fine,just need to change:

((MasterPageTypeName)Page.MasterPage ).MyText = "test";

to ((MasterPageTypeName)Page.Master ).MyText = "test";

that's it,you are done.

Avishek