ASP.NET or MVC - How to Referece master or layout page's content
4/3/2014·5 min read
In ASP.NET and ASP.NET MVC there're cases when you want to reference master(Layout) page's content, there're few ways to doing that, this's article try to list all of them for referenece.
- access Master Page Content
- add to ContentPlaceHolder control(from your C# Server side)
- another way to add to ContentPlaceHolder control (C# server side)
- add value to master page from ASPX's design page
- access Layout Page content (ASP.NET MVC)
- add value to Layout Page (from client html side)
- add value to layout Page (from C# Server side)
1. access Master Page Content
1) add to ContentPlaceHolder control(from your C# Server side)
it's not only for javascript path, you could add anything to your master page.
2) another way to add to ContentPlaceHolder control (C# server side)
3) add value to master page from ASPX's design page
2. access Layout Page content (ASP.NET MVC)
1) add value to Layout Page (from client html side)
if you want to add following jQuery path at the end of the body tag on ASP.NET MVC
2) add value to layout Page (from C# Server side)
There're few ways you could add value to you C# server side, here's provide one way to use ViewBag.
So, following're steps to do that.
In this way, you could add anything you want to your parents page.