Navigating away from page referenced using iframe - asp.net

What I have at the moment is a page which I am using as a sirt of site master for my html pages. The way I am doing this is by referencing the master page using this line of code:
<iframe scrolling="no" style="width:100%;" frameBorder="0" src="WebForm1.aspx"></iframe>
Now that works fine, I can create a new page and reference that, and then the content from that page will appear on any page referencing it.
But I have a problem, what I want Is if you click the navigation button that is in header of a page that is referencing this site master; it navigates away but only the iframe will hold the webpage, and the main content will still be the same.
For example:
In the master page I am referencing using the Iframe, I have some code that when you click on a button it navigates away, ok. But if I go into a page that is referencing the master and click the button, the new web page will only open in the iframe section at the top of the page.
Sorry for this complicated question, if anyone understands it, then any advice would be helpful!
The page that is referencing the master:
http://codepad.org/IyrDxAf9
The master page itself:
http://codepad.org/XMu67H1M
PS...I am coding this in asp.net using html
The aim of all this is to create a master page for html, but I am not having much luck with it

You can set the following in your webform1.aspx page:
<base target="_parent" />
This will target all the links on that page to the 'parent' window. You can also do this with individual links.
Seeing as you are using .aspx pages here, is there a reason why you are not using the built in master page functionality?

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.

how to prevent loading aspx pages in single page asp.net website

I developed a single page website (like windows 8 tiles) and i put my aspx pages in iframe when i click a tile in default page it opens the related iframe in same default page. Its all working fine.
Here the problem is when default page is loading all the iframe aspx pages are loading it is unwanted and there it takes lot of time to load all the pages, it is not necessary to load the pages when i click the tile then the related iframe page will open.
How did i prevent this loading aspx pages ?
A possible way around this would be to leave the src attribute of each iframe empty and use javascript to change it on click.
For example, you could create an iframe like
<iframe id="ifrm" src=""></iframe>
and add to the tiles an onclick event with the following javascript:
document.getElementById['ifrm'].src = "http://www.test.com";

How to avoid refreshing of masterpage while navigating in site?

In my website, I have created a masterpage and attached all of my pages to it.
My masterpage structure contains a header and a footer. On the left it has a treeview control, which i have attached to all my pages, and on the right there is a contentplaceholder to show the content of respective pages.
My problem is that when I click any link in the treeview it refreshes the whole masterpage and open the respective page. I wish to avoid this refresh. Means it should show the contents of page on right side contentplaceholder without refreshing the whole page.
I have seen people suggesting to use iframes. But for using iframes I shall have to restructure my website. Is there any other solution than iframes and with minimal changes to the work that I have done?
You will probably want to look at using AJAX to stop this from happening. You will want to read up on using an UpdatePanel. Below are some good articles that goes over this:
http://geekswithblogs.net/ranganh/archive/2007/05/11/112405.aspx
http://msdn.microsoft.com/en-us/library/bb399001.aspx
You also have the option of using jQuery to handle your AJAX calls. While I typically prefer the use of jQuery when using AJAX, I am not sure I would use it in your situation. If you would like to look at what it offers take a look at these links:
http://api.jquery.com/jQuery.ajax/
http://sixrevisions.com/javascript/the-power-of-jquery-with-ajax/
You could put the content you wish to change inside an asp:UpdatePanel that way that will be the only thing that is repainted (it uses AJAX under the hood):
http://msdn.microsoft.com/en-us/library/system.web.ui.updatepanel.aspx
The master page class derives from the UserControl class and the master page is like a child control. So we can say that master page is not a true page, when a page loads we can notice the navigation URL in the address bar is the content page's but not the master page! so we cannot refresh a content page without refreshing master page.
there is one way to avoid flickering the page by adding the code in < Head > section in the masterpage.
<meta http-equiv="Page-Enter" content="blendTrans(Duration=0)"/>
<meta http-equiv="Page-Exit" content="blendTrans(Duration=0)"/>

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.

External Link inside a webform (using master page)

I am trying to get one of the webforms in my application to link to another website, outside of my application. I can get the page to load as a new webpage in my browser easily but I need to keep my masterpage in view.
Can this even be done?
TIA
You could use the IFRAME tag:
<iframe src="http://www.google.com" title="Google's Website">
<!-- Alternate content for non-supporting browsers -->
</iframe >

Resources