There are two ways to get content about a master page
1 find the control ID by FindControl
Required in this event ~ because the content page is loaded first in Page_Load and then the master page is loaded
protected voidPage_loadcomplete (Objectsender, EventArgs e) {Label2.Text="now the time is"+ (Master.findcontrol ("Label1") asLabel). Text; if(request.querystring["ID"] =="Dy") {(Master.findcontrol ("Image1") asImage). IMAGEURL ="~/images/ml0069.jpg"; } }
2 by strong references
<%@ page language="C #" masterpagefile="~/masterpage.master" codefile= "Default2.aspx.cs " inherits="Default2 " title="Untitled page" %><%@ MasterType virtualpath="~/ Masterpage.master" %>
You can then define public properties or methods in the master page
Public string GetUserName () { return Page.User.Identity.Name; }
Called in the content page
" Welcome to visit " + master.getusername ();
How to get master page controls for an ASP page