Exforsys.com
 
Home Tutorials ASP.NET 2.0
 

ASP.NET 2.0: Referencing Master Page Members

 

ASP.NET 2.0: Referencing Master Page Members - Page 2

Page 2 of 2


.


.




The < span > element marked runat=server is mapped to an HTMLGenericControl object and its text content is exposed through the InnerText property. This property is wrapped by a new public property “SubTitle” that gets and sets the value of the InnerText property on the < span > tag.


Now this property can be invoked from the master if the SubTitle propertyis defined on the MasterPage class. This is because the MasterPage class represents the masterpage object which is compiled at runtime. The ClassName attribute on the @Master directive allows the assignment of user defined names to the master page class. Therefore the master property must be cast to the actual type to be able to call custom properties. The following code will have to be added to the content page


((MasterPage)Master).SubTitle= “Welcome”;




Now add the following code to the content page.


< script runat= “Server” >
.........Void Page_Load(object sender, EventArgs e)
.........{
..................Master. SubTitle = “Welcome”;
.........}
< /Script >


 


 






First Page: ASP.NET 2.0: Referencing Master Page Members


Read Next: ASP.NET 2.0 :Changing Master Pages Dynamically



 

 

Comments


Ajatsahtru said:

  First of all thnx a ton for a great post. I'm a biggner to asp.net.
I'm not getting this line:

The following code will have to be added to the content page
((MasterPage)Master).SubTitle= “Welcome”;

Where to put this line exactly??
Hope u reply this stupid question.
Regards
May 29, 2009, 2:33 am

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape