Content page not displaying images - asp.net

I have a project with a master page at the root level and multiple content pages which are at the root level as well. Everything has been looking fine until I created a new folder and put a new content page in that folder. None of the images are displaying for that particular page. I'm sure its something simple that I'm missing.
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="SupertonesInstallation.aspx.cs" Inherits="Articles_SupertonesInstallation" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Home" Runat="Server">
content
</asp:Content>

Related

How to show an outside website like google or bing within a master page

I have created a website using a master page. One of the links within the master page is for Googles website. I can display the google website within the master page by inserting the website within a Iframe, but the problem is when I do a search in google and I click on the links some of the links within google do not open. After some reading I find that some websites do not allow their sites to open within an iframe "You have to check for HTTP response header X-Frame-Option of those sites. if its value is "DENY or SAMEORIGIN", then you can not load those website in the iframes.".
So does anyone know of another way to display an outside website within a master page?
This is my content page
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="Google.aspx.cs" Inherits="OnCallWeb.Google" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
<p>
<iframe src="https://www.google.com/webhp?igu=1" style="width:100%;height:700px;"></iframe>
</asp:Content>
This is on my master page.
<li>Google</li>
Found Google no longer supports Iframes

Loading ContentPlaceHolders from separate files

I am trying to create a Main.master page with two ContentPlaceHolder sections.
When I load the default page, it only renders ContentPlaceHolder1, I have to actually load Second.aspx to see the second ContentPlaceHolder. Why?
In my Main.master I have:
<%# Master Language="C#" AutoEventWireup="true" CodeFile="Main.master.cs" Inherits="Main" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
<asp:ContentPlaceHolder id="ContentPlaceHolder2" runat="server"></asp:ContentPlaceHolder>
</div>
</body>
</html>
Additionally, I have created two additional pages Default.aspx and Second.aspx:
Detault:
<%# Page Title="" Language="C#" MasterPageFile="~/Main.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
HOW HOW HOW HOW
</asp:Content>
Other page is
Second:
<%# Page Title="" Language="C#" MasterPageFile="~/Main.master" AutoEventWireup="true" CodeFile="Second.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
COW COW COW COW
</asp:Content>
Its only rendering the first PlaceHolder, how can I have separate content files and have the both rendered on the same page?
You have to ask yourself: If you navigate to Default.aspx, how will your application know to grab the content in Second.aspx? Simply put: it won't.
First, here's the MSDN on the ContentPlaceHolder.
You can have as many ContentPlaceHolders on your masterpage as you want, and EACH page can either render into these content areas or NOT.
So your Default.aspx can look like:
<%# Page Title="" Language="C#" MasterPageFile="~/Main.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
HOW HOW HOW HOW
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
COW COW COW COW
</asp:Content>
And you will get the results you are looking for.
Now, there are ways you can render an OUTSIDE html file INTO one of these content placeholders (one way would be javascript) - but (and please, someone correct me if I'm wrong) there won't be a way to do it with an ASPX webpage, codebehind or not.
To touch on your question:
how can I have separate content files and have the both rendered on the same page?
You may want to look into this:
How to include a partial view inside a webform

Is there any possibility to add master page for more then one existing .aspx page?

I already made update.aspx page and view.aspx page now I want to assign master page that to these pages...can someone help me out ?
Create new master page names Site.Master, move everything you want from update.aspx into master, so probably Head section html content, and then in the body put the placeholder:
<asp:ContentPlaceHolder runat="server" ID="MainContent" />
Now when "shared" master content is moved from your update.aspx/view.aspx, you just need to wrap everything that's left in those pages into this:
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
your update.aspx page content
</asp:Content>
In first line of your page you should have something like <%# Page ... attributes ... %>, add new attribute that points to the master page: MasterPageFile="~/Site.Master"
For the reference, create new WebForms project and you'll get few sample pages. See how should a HTML content in the master page look like, and how to wrap page content of you aspx page.
End result should look something like this:
Site.Master
<html><head>...</head>
<body>
some master body html content
<asp:ContentPlaceHolder runat="server" ID="MainContent" />
more html here
</body>
<html>
Then the page:
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
your update.aspx page content
</asp:Content>
i suppose your master page is Main.Master
the first step
in the update.aspx page and view.aspx page (at the top )
make MasterPageFile attribute = "~/Main.Master" this is the code
<%# Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="update.aspx.cs"
the second step
remove the head and title and body and html tags from the update.aspx page and view.aspx page
and put tow content two content place holders (the same in the master page) in your pages(update.aspx and view.aspx)
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"></asp:Content>
the previous content place holder represents the head of this page you can put in it any css or java script code or references
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"></asp:Content>
second placeholder represents the body of this page you can put in it the body of your page(update.aspx)

Style sheets only for the content page of a Master page in asp.net

I have a master page which has 10 content pages linked to it.
Now a CSS file attached to the Master page gets applied to the content page on its own.
If however, I want a different CSS file only for one of the content pages (and none of the master page CSS should apply to it). How to do it??
You can add that style to a placeholder of the specific page not the masterpage
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="Detail.aspx.cs" Inherits="Test.Detail" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<link href="<%= Page.ResolveUrl("~/styles/style.css")%>" type="text/css" rel="stylesheet" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>

ASP.NET Different Layouts within 1 Site

A client has an ASP.NET website with master pages and a layout directory.
What we need is 2 different layouts on the site. Can I easily have two layouts with different master pages on the same site?
What's the best way to do that?
See Setting an ASP.NET Master Page at runtime. You can set any page to use any masterpage programmatically at runtime.
Yes. Just create two different master pages and point the corresponding aspx pages to the desired masterpage.
Example:
page1.aspx
<% # Page Language="C#" MasterPageFile="~/Master.master" Title="Content Page 1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Main" Runat="Server">
Main content.
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Footer" Runat="Server" >
Footer content.
</asp:content>
page2.aspx
<% # Page Language="C#" MasterPageFile="~/secondary.master" Title="Content Page 2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Main" Runat="Server">
Main content.
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Footer" Runat="Server" >
Footer content.
</asp:content>

Resources