how to show aspx page in contentplaceholder of masterpage - asp.net

I have a master page in my website.
I have two contentplaceholder on that master page.
In one contentplaceholder i have some links on which click I want to redirect
to the corresponding page in the second contetplaceholder on the same master page.
how can i do this....?
pls help ..?

I think you may have missed something here. When you use master pages you have content pages instead. The content page defines the area defined by the content place holder in your master page. When you create a content page you use the contentplaceholder tags to show your page content within the master page. It might be worth reading up the master pages tutorials on the ASP.NET website.

I don't see a problem here. Just make the .aspx pages use the same master page and set the link locations to .aspx pages.

From what it sounds like, you'll want to use a sitemap instead of the first contentplaceholder. Here is a description of them: http://msdn.microsoft.com/en-us/library/yy2ykkab.aspx

Related

Not able to add form tag inside Content Page

I have a Master Page and a Content Page. I have Check In Check Out small form in Master Page and I have a Contact form in Content page. But while running the website, I am getting the error which says:A page can have only one server side form tag. When I remove the form tag from the Content Page. Then,it says the Textbox should be placed within a form tag. But I want both the forms,since both are necessary. So please help me so that I can have both the forms.
There can be only one <form> tag on the whole page, that is just how webforms work. In your case it is in the master page. The pages using the Master do not and should not have <form> tags.
But from your question it seems that you think you are using master pages, but are actually not. See this page as to how the .aspx pages are supposed to look with master and child pages.
https://learn.microsoft.com/en-us/aspnet/web-forms/overview/older-versions-getting-started/master-pages/creating-a-site-wide-layout-using-master-pages-cs
It is not possible to add more than one form in a single aspx file. Otherwise try to use iframe in that page.Inside the iframe we can use another aspx page.

Is it possible to create a master page which selects another master page?

I have a master page with name MasterPage.master.
Now I want to create another master page (MasterPage2.master) that its MasterPageFile is MasterPage.master,
But when I create MasterPage2 and then create a webform from MasterPage2, there isn't any ContentPlaceHolder in this webform.
Please explain for me...
What you're looking for is nested master pages.
Google it and you'll have a ton of tutorials. Top 2 results from google:
http://msdn.microsoft.com/en-us/library/x2b3ktt7(v=vs.100).aspx
http://msdn.microsoft.com/en-us/library/bb547109(v=vs.100).aspx
Most likely either:
MasterPage2 is using the ContentPlaceHolder from MasterPage but not adding another ContentPlaceHolder for your content page to use
the ContentPlaceHolder on MasterPage2 has the same IDs as the one on MasterPage
Make sure MasterPage2 has a ContentPlaceHolder with a unique identifier.

Reload only Content Pages Inside the Masterpage

I have more than 100pages in my project & a single master page for all this. My masterpage has links to different pages. I want to change only the ContentPages( Child Pages) & my masterpage should not get reloaded.
For Example:
My Master page is : SiteMaster.master
Child Page1: Add.aspx
Child Page2: Sub.aspx
When I execute, Add.aspx comes inside the SiteMaster.master. Know, When I click the sub.aspx link inside the Add.aspx, only add.aspx page should be changed & sub.aspx must be loaded. I don't want to reload the master page.
If possible, please post some examples or links.
Your expected behavior is not exactly how master pages work. There may be ways to achieve a no postback solution in this scenario but the easiest one would be to use an <IFrame /> (which is usually frowned upon)
Master page is part of your pages. It's not loading separately.
Simple explanation:
ASP.NET engine takes your aspx and puts it inside the master page and then renders it as one page, then serves it to user.
If this is not what you want and you want that only content of your master page be loaded, then you should not use master pages at all! It's against nature of master pages. they act like skins for aspx pages.
Search for HTML IFrame tag and don't use master page.
P.S: IFrames are not used widely in this days.

Loading ScriptManager only once either from Master page or Content page

I have an web application of 200 web pages and all has a single master page. Most of the content pages use AJAX controls so most of content pages has its own ScriptManager. Now I have a requirement to add a link with HoverMenuExtender control and for that I need to put ScriptManager in the Master page, but it is working only in the content pages where there is not ScriptManager.
All the other content pages which has ScriptManager throws the error Only one instance of a ScriptManager can be added to the page. I don't want to work on most of the content pages again to remove ScriptManager.
Is there any easy way to do this something like coding in Master page which decides if there is already ScriptManager already, then don't load it.
Take a look at ScriptManagerProxy. This is what I think you need.

show an aspx page in content tag

I have a master page(MyMasterPage.master) with two content place holders. I wanna show another aspx page(MyHeader.aspx) in the 1st content place holder of a content page(MyContentPage.aspx) that uses my master page.
You should be using user controls for reusable components of a pages. Create a Header.ascx file instead of a .aspx. You can then drag that into your ContentPlaceHolder from the solution explorer when in design mode.
http://msdn.microsoft.com/en-us/library/y6wb1a0e.aspx
I would use UserControls. MyHeader.ascx.
I echo the prior commenter's suggestion to use a usercontrol if possible.
If you really want to keep your existing aspx page; you might want to take a look at using an IFrame to accomplish this.

Resources