content placeholders pages not showing inside master page - c#

I'a currently working on C# aspx.net project, and all of a sudden the pages that should load inside master page are not shown, it's like "hidden", only master page is showing, i didn't do nothing revelant to it, i think.
It's getting me insane because i already loaded a backup that i got, and the same problem occurs. So maybe i did something wrong to my Visual Studio 2019?
Does that ever happened to anyone?
I've tryed to change the Netframework from 4.5 to 4.6 but the problem persists.
if i inspect the page on google devtools, the page's are there, but not showing on the content placehonder.
Example of my master page:
<%# Master Language="C#" AutoEventWireup="false" CodeBehind="Masterpage.Master.cs" Inherits="WORKFLOW_FACTURE.Site1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
....
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<div id="wrapper">
</div>
<div id="page-wrapper">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<!-- /#page-wrapper -->
</body>
</html>
example of one page that should be loaded whenthe user enter the masterpage:
<%# Page Title="" EnableEventValidation="false" Language="C#" AutoEventWireup="false" MasterPageFile="~/Masterpage.Master" CodeBehind="Indicateurs.aspx.cs" Inherits="WORKFLOW_FACTURE.Indicateurs" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<form runat="server">
....
</form>
<script type="text/javascript">
...
</script>
</asp:Content>

I alredy had that same problem on my asp.net application, where bootstrap classes weren't recognized.
It can happen for two main reasons:
1 - *the links *.css / script .js are being called from the master page at bad order, and because of that, dind't load properly.
2 - Calling bootstrap.css instead of bootstrap.min.css, that happened to me, i think that's because of the load time that can be relevant to the content page.

Related

Need to Load .aspx page asynchronously through Master page hyperlink event using update panel in c#

I need to load pages asynchronously using asp.net C#.
I have a master with Two(2) hyperlink controls and One(1) ContentPlaceHolder.
I do not need page refresh or mute the page refresh to load page Async by clicking the hypelink control given on master page.
Code for Main.Master page, Home.aspx page and the products.aspx is given below.
Main.Master
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Main.master.cs" Inherits="AsyncPageLoadFromMasterLink.Main" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div id="navbar">
<asp:HyperLink ID="lnkHome" NavigateUrl="~/home.aspx" runat="server">Home</asp:HyperLink>
<br />
<asp:HyperLink ID="lnkProducts" NavigateUrl="~/products.aspx" runat="server">Products</asp:HyperLink>
</div>
<div id="main">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
home.aspx
<%# Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="home.aspx.cs" Inherits="AsyncPageLoadFromMasterLink.home" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h1>This is Home Page</h1>
</asp:Content>
products.aspx
<%# Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="products.aspx.cs" Inherits="AsyncPageLoadFromMasterLink.products" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h1>This is Products page</h1>
</asp:Content>
Bundle of Thanks in Advance
I bet you need to add the hyperlinks to the update panel and bind the hyperlink's OnClick() event to the update panel's trigger.

MasterPage Issue - ASP.NET Webform [duplicate]

This question already has answers here:
Content controls have to be top-level controls in a content page or a nested master page that references a master page
(2 answers)
Closed 6 years ago.
I have added a masterpage to my project, and now when i try to inherit this masterpage to one page, I get this error:
'Content controls have to be top-level controls in a content page or a nested master page that references a master page.'
master_page.Master:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="master_page.master.cs"Inherits="KitchenCounter.master_pages.MasterPage"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:Content runat="server" ContentPlaceHolderID="MainContent">
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</asp:Content>
</head>
<body>
<asp:Content runat="server" ContentPlaceHolderID="MainContent">
<asp:ContentPlaceHolder ID="MainContent" runat="server">
<div class="menuBar">
<ul>
<li class="hvr-bounce-to-bottom active"><a>Home</a></li>
<li class="hvr-bounce-to-bottom">Account</li>
<li class="hvr-bounce-to-bottom">Recipes</li>
<li class="hvr-bounce-to-bottom">Contact</li>
</ul>
</div>
</asp:ContentPlaceHolder>
</asp:Content>
</body>
</html>
Index.aspx:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="KitchenCounter.pages.Index" MasterPageFile="~/kitchencounter/master_pages/master_page.Master"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Kitchen Counter | Home</title>
<link rel="stylesheet" href="kitchencounter/css/main.css" />
</head>
<body>
</body>
</html>
Any ideas where to start with this? Any help is appreciated.
The idea behind a master page with content pages is that your master page contains items that should appear on every (or most) page in your site, with placeholders left where a content page will fill in information specific to that page. With that premise in mind, there are a few things to change:
You put the content controls in the master page; they need to go in the content page, which in your case is Index.aspx.
Additionally, your content page should only contain as its top-level controls tags - you use the ContentPlaceHolderId attribute to match the content inside the tags on your content page to the places where the content belongs on the Master page.
Finally, your markup for your navigation bar needs to be outside of the control on your Master page. The control is just that - a placeholder; nothing goes inside of it.
So try this:
master_page.Master:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="master_page.master.cs"Inherits="KitchenCounter.master_pages.MasterPage"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<div class="menuBar">
<ul>
<li class="hvr-bounce-to-bottom active"><a>Home</a></li>
<li class="hvr-bounce-to-bottom">Account</li>
<li class="hvr-bounce-to-bottom">Recipes</li>
<li class="hvr-bounce-to-bottom">Contact</li>
</ul>
</div>
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
</body>
</html>
Index.aspx:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="KitchenCounter.pages.Index" MasterPageFile="~/kitchencounter/master_pages/master_page.Master"%>
<asp:Content runat="server" ContentPlaceHolderID="head">
<title>Kitchen Counter | Home</title>
<link rel="stylesheet" href="kitchencounter/css/main.css" />
</asp:Content>
<asp:Content runat="server" ContentPlaceHolderID="MainContent">
The text that is specific for your Index page goes here.
</asp:Content>

Where are navigation elements declared in default Web Forms template?

VERY very basic question. I'm trying to learn ASP.NET. I created a default website1 in VS 2013 Community I get a ton of files. When I run the app in IS, the default.aspx web page appears and all is OK, but above the web page is a banner with links to contact.aspx, login.aspx. register.aspx, etc. and I cannot find where that banner is? It's not on default.aspx. Where is it? Seaching the project for "Contact.aspx" only returns one result, the page itself, as an example.
It's probably coming from a Master Page. Look at the <%# Page %> header at the tops of the .aspx files. You'll see they reference a master page. A Master Page is used to provide structure to the site. It means you don't have to write the same HTML for common elements on every single content page. Content pages (.aspx) then can have their content inserted into the Master Page. And yes, you can nest master pages. This is all done through the <asp:ContentPlaceHolder /> (higher level Master Page) and <asp:Content /> (nested Master Page or Content Page) tags.
Let's look at an example:
MasterPage.master
<%# Master Language="C#" %>
<!DOCTYPE html>
<html>
<head runat="server" >
<title>Master page title</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="Main" runat="server" />
</div>
<div>
<asp:ContentPlaceHolder id="Footer" runat="server" />
</div>
</form>
</body>
</html>
Default.aspx
<%# Page Language="C#" MasterPageFile="~/MasterPage.master" Title="Content Page 1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Main" Runat="Server">
Main content here.
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Footer" runat="Server" >
Footer content here.
</asp:Content>
The resulting HTML will look like this on the client when you access Default.aspx:
<!DOCTYPE html>
<html>
<head>
<title>Content Page 1</title>
</head>
<body>
<form id="ContentPage_form1">
<div>
Main content here.
</div>
<div>
Footer content here.
</div>
</form>
</body>
</html>
Take special note of how the ID of the form changed from the server side to the client. This trips a lot of people up when they start doing client side JavaScript. If you want the ID to not change, you have to add the ClientIDMode="Static" attribute to the control (you can also set it at page, web.config, or machine.config levels).

page is missing a HtmlHead control which is required for

I have a website project that include a masterpage : when ı tried to add ajax control toolkit EDITOR, I am getting a error like This page is missing a HtmlHead control which is required for the CSS stylesheet link that is being added. Please add <head runat="server" />.
when ı add masterpage ContentPlaceHolder1 a <form runat="server"></form>, there arent any error but I don't want to add each masterpage form element
how can ı solved this problem?
<%# Page Title="" Language="C#" MasterPageFile="~/AdminPanel/Admin.Master" AutoEventWireup="true" CodeBehind="Tadd.aspx.cs" Inherits="Tadd.AdminPanel.Tadd1" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></ajaxToolkit:ToolkitScriptManager>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<form runat="server">
<cc1:Editor ID="Editor1" runat="server" />
</form>
</asp:Content>
You should have an head tag in your Master-Page which is run at server:
<head id="page-head" runat="server">
...
</head>
And positioned it in top of your page/html.

Using nested Master Pages

I'm very new to ASP.NET, help me please understand MasterPages conception more.
I have Site.master with common header data (css, meta, etc), center form (blank) and footer (copyright info, contact us link, etc).
<%# Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="_SiteMaster" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="tagHead" runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="styles.css" type="text/css" />
</head>
<body>
<form id="frmMaster" runat="server">
<div>
<asp:ContentPlaceHolder ID="holderForm" runat="server"></asp:ContentPlaceHolder>
<asp:ContentPlaceHolder ID="holderFooter" runat="server">Some footer here</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
and I want to use second master page for a project into sub directory, which would contains SQL query on Page_Load for logging (it isn't necessary for whole site).
<%# Master Language="C#" AutoEventWireup="true" CodeFile="Project.master.cs" Inherits="_ProjectMaster" MasterPageFile="~/Site.master" %>
<asp:Content ContentPlaceHolderID="holderForm" runat="server">
<asp:ContentPlaceHolder ID="holderForm" runat="server" EnableViewState="true"></asp:ContentPlaceHolder>
</asp:Content>
<asp:Content ContentPlaceHolderID="holderFooter" runat="server">
<asp:ContentPlaceHolder ID="holderFooter" runat="server" EnableViewState="true"></asp:ContentPlaceHolder>
</asp:Content>
But I have a problem: footer isn't displayed.
Where is my mistake? Am I right to use second master page as super class for logging?
Project page looks like this:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" MasterPageFile="~/Project.master" %>
<asp:Content ContentPlaceHolderID="holderForm" runat="server">
<p>Hello World!</p>
</asp:Content>
<asp:Content ContentPlaceHolderID="holderFooter" runat="Server">
Some footer content
</asp:Content>
I've been working with nested master pages and have run in to something similar. From what I see where you have "Some footer here" in the Site.Master is where the problem lies and I've had similar problems with having content with-in a contentplaceholder tag. if you try this instead
<asp:ContentPlaceHolder ID="holderFooter" runat="server"/>Some footer here
Then you should be able to see the footer content.
I'm not sure I'd use master pages for this. If it's really just going to do logging, I'd implement IHttpModule, register it in web.config, and then check whether or not to log based on the path of the request. I think of master pages as being about content rather than other processing such as logging.
See the IHttpModule walkthrough on MSDN for an example - in your BeginRequest handler, you'd probably check the request path and log appropriately if it matched.
Apologies if I misunderstood what you're trying to do though.
You should leave your ContentPlaceHolder empty, for it gets substituted by the content of the Content in your actual Page...
When you move the "Some footer here" text to your Content, you will see your lines of text :)
HTH
This link gives a simple explanation on Master pages,
http://waxtadpole.wordpress.com/2009/01/16/master-page-content-not-visible-visual-studio-2008/
The question are you right to use child Master pages in this instance - I would say master pages should be helping you solve issues around building a consistent layout, not for whether or not logging should occur.
The problem is, when the text elements placed inside Default.aspx are put in their relative Content Placeholders, they are written on the placeholders of your Site.master page and not those of Project.master (which have the same names).
You should resolve the naming conflict, by assigning different ContentPlaceHolderIDs to the the placeholders in Project.master (this means you'll also have to change the references in Default.aspx).
This would be your Project.master file:
<%# Master Language="C#" AutoEventWireup="true" CodeFile="Project.master.cs" Inherits="_ProjectMaster" MasterPageFile="~/Site.master" %>
<asp:Content ContentPlaceHolderID="holderForm" runat="server">
<!-- whatever... -->
<asp:ContentPlaceHolder ID="holderFormInternal" runat="server" EnableViewState="true"></asp:ContentPlaceHolder>
<!-- ... -->
</asp:Content>
<asp:Content ContentPlaceHolderID="holderFooter" runat="server">
<asp:ContentPlaceHolder ID="holderFooterInternal" runat="server" EnableViewState="true"></asp:ContentPlaceHolder>
</asp:Content>
And thus, your .aspx pages that use the Project master page instead of the global Page.master must be changed to:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" MasterPageFile="~/Project.master" %>
<asp:Content ContentPlaceHolderID="holderFormInternal" runat="server">
<p>Hello World!</p>
</asp:Content>
<asp:Content ContentPlaceHolderID="holderFooterInternal" runat="Server">
</asp:Content>
If the only reason is to implement loggin why would you mess around with masterpages?
If the logging isent supposed to display any text!?
You either do as Skeet proposed with an IHTTP handler.. Or lazier one would be do have a class that derives from webpage and implement logging in that class and make your pages that need logging dervice from that..
ex:
public class LoggingPage : : System.Web.UI.Page
{
public override void OnLoad()
{
// Do logging
}
}
partial class OneOfTheWebPages : LoggingPage
{
public void onLoad()
{
base.onLoad();
}
}
I may be misunderstanding your problem - but from the code you've posted, there isn't anything in the footer.
In your Project page, the <asp:Content> tag for the holderFooter content place holder doesn't have anything in it.
I have next inheritance tree:
Site.master <-- Page1.aspx
<-- Project.master <-- Page2.aspx
And I don't know why Page2 display only content of itself and it's master page - Project. But doesn't display a content of Site (as Page1 does) Why? What have I to write for doing that?

Categories

Resources