Click here to Skip to main content
15,868,062 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I am developing one web site which contains one Masterpage and multiple content pages. Initially when site get loaded i want one content page to be loaded in my master page. Remaining pages should get loaded on menu item click. How to do it?
Thanks in advance.
Posted

Presumably you're trying to do more than just having static pages (for which you don't need ASP.NET at all - just use old-fashioned HTML).
So is your MasterPage like a template that starts off with some default content?
And you then want to load what is essentially the same page but change the content?
If so, this sounds like a content management system. Is that right?
For a CMS you're going to need:
1. Underlying database (or some equivalent way of storing your chunks of content).
2. ASP.NET code that grabs your URL or postback (or . . .), works out which content items are needed and adds them into your template page in the right place.
3. Probably some means for a user to edit the content.
This can be anything from fairly simple to very complex and there are probably as many ways of doing it as there are content management systems. Personally, I'd start by looking at an existing CMS, understanding a bit about how it works and using that to inspire your design.
Which CMS you look at is up to you, but concepts are probably more important than code - when I first started on this I looked at Joomla (written in PHP) which is fairly sophisticated, but even just using the administrative access to set up / manage a simple site (without looking at any of the PHP) helps to understand what problems you might face.
 
Share this answer
 
Comments
Nish Nishant 30-Apr-11 12:36pm    
Good answer, my vote of 5!
RaviRanjanKr 30-Apr-11 13:37pm    
Nice Answer! my 5 :)
Hi,
I think you need to have very clear understanding on MasterPage before using in your project, otherwise though your specified problem shall be solved now but you will face difficulty later in the project.
You will get very basic understanding and application of MasterPage in asp.net project from below link
http://www.dotnetperls.com/master-page[^]
another tutorial
http://www.youtube.com/watch?v=epaavQsb950[^]

And solution to your posted problem is simple, link those page with your menu item links. For example you have master page default.master , this page is used by 2 content page say, default1.aspx and default2.aspx. Now link these 2 pages with your menu link like,
XML
<a href='default1.aspx'>menu item 1 </a>
<a href='default2.aspx'>menu item 2 </a>


Thats it, you are good to go. Hope this will help.
 
Share this answer
 
Comments
Nish Nishant 30-Apr-11 12:36pm    
Good answer, my vote of 5!
RaviRanjanKr 30-Apr-11 13:37pm    
Nice Answer! My 5 :)
Shahriar Iqbal Chowdhury/Galib 30-Apr-11 16:13pm    
thanks guys :)
u can use UserControls and master page ...
on master page replace a ContentPlaceHolder And
replace this code inside master page ( Page_Load ) event ...
<br />
 protected void Page_Load(object sender, EventArgs e)<br />
    {<br />
        Control MyUserControl;<br />
        MyUserControl = LoadControl("~/UserControls/index.ascx");// youre UserControl Address<br />
        ContentPlaceHolder1.Controls.Add(MyUserControl);<br />
    }<br />
<br />
<br />
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900