I've just create a new MVC project, and have made no changes at all, but when I try and view the ChangePasswordSuccess view in design mode, I get the error:
The page has controls that require a Master Page reference, but none is supplied.
The page has no controls except for a content control and literal text, and it does have a master page reference. Anyone know what's up?
<%#Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="ChangePasswordSuccess.aspx.cs" Inherits="BasicMvcApp.Views.Account.ChangePasswordSuccess" %>
<asp:Content ID="changePasswordSuccessContent" ContentPlaceHolderID="MainContent" runat="server">
<h2>Change Password</h2>
<p>
Your password has been changed successfully.
</p>
</asp:Content>
No sooner asked than noticed. The default ChangePasswordSuccess view's Page directive is missing the word Page.
Related
I am using umbraco 7 and i'm not really good on MVC, so i am using webforms and when i try to use a webform template i can't add content on the page, just on the template.
Here i use in de default.master file the contentplace holder like this:
<div id="mainContent">
<asp:ContentPlaceHolder id="MainContent" runat="server">
</asp:ContentPlaceHolder>
</div>
Then i create the template called "Text Webform" and this is the code:
<%# Master Language="C#" MasterPageFile="~/umbraco/Masterpages/Default.master" AutoEventWireup="true" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
This content is displayed
Am i forgetting some code to add here?
</asp:Content>
Click on this to see screenshot
The problem is when i try to add content in a page that is using "Text Webform" template, that content is not displayed, as you can see on the screenshots here
I'm sure i need to add some content in the Text Webform template but i don't know exactly what and i'm desperate, please somebody provide any help,
Thanks.
You have to define what fields (eg properties from your document type) to show where in your template. I believe this is what you are looking for? https://our.umbraco.org/documentation/Reference/Templating/Masterpages/umbracoitem - just
Ok, now i can explain it better,
I just want the equal function to #CurrentPage.GetGridHtml("content", "fanoe") using a webform template..
I have a using ASP.net C# firstly I have created a webform FrmFirst.aspx. Then I have created a master page. Now I have to add my first page to master page then I am facing the same error :
I am using this code to add my first page to Master page
<%# Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage.master" CodeFile="FrmCustomerMaster.aspx.cs" Inherits="FrmCustomerMaster" %>
Tell me my Problem !! Thanks ....
You need to change your body to content sections. The master page works with contentplaceholders: your content pages need to provide the content for these placeholders
see LINK
if your master page contain this code
<asp:contentplaceholder id="Main" runat="server" />
your page that Inherits from master should have
<asp:Content ID="Content1" ContentPlaceHolderID="Main" Runat="Server">
</asp:Content>
I am using .net 2008 for developing web application.
So I created a master page and some other pages. I want to apply master page to all other pages but I'm not getting it. Earlier i use .net2005 here there is option when we created a new page in application and check the master page option, but in .net2008 this option is not there so please tell me how to do it. I'm new to .net 2008 .
Please tell me
Thank you
If you want to manually set the masterpage for pages you have already created you can do the following: In the Page directive of your ASPX pages you set the masterpage like this:
<%# Page Language="C#" MasterPageFile="~/MasterPages/Master1.master" Title="Content Page"%>
Your MasterPage defines a few Content areas. You then should reuse those in your page and fill them with the local content.
When adding a new page the documentation says that when adding a Web Forms page you can select the Select master page check box, and then click Add. Then the Select a Master Page dialog box should appear.
You indicating that in your question
"when we created a new page in application and check the master page option"
If you are using a web application when you wan't to add a page with masterpage
you should add the page like this
Project ->
Add New Item ->
Web Form Using Master Page (instead of selecting Web Form)
Then you will have the option to select the masterpage
Use this code:
<%# Page Title="test" Language="VB" MasterPageFile="~/MasterPageName.master" AutoEventWireup="false" CodeFile="PageName.aspx.vb" Inherits="PageNameClass" %>
<asp:Content ID="Content1" ContentPlaceHolderID="maincontent" runat="Server">
//here you can add you page data start from form tag till end of form tag and remove everything else.
</asp:Content>
Can i use namespace which is imported on masterpage ?
i can import and use namespace on masterpage like that..
<%# Import Namespace="utl=portal.lib.SnkUtilities" %>
and on markup;
<a href='<%= "/" + utl.getSomeString() + "/cart.aspx" %>'>
but if want to use same namespace on a contentpage, i have to import same namespace on content second time as follows:
<%# Page Title="" Language="C#" MasterPageFile="~/Master" AutoEventWireup="true" CodeBehind="Account.aspx.cs" Inherits="portal.secret.Account" %>
<%# Import Namespace="utl=portal.lib.SnkUtilities" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<%= utl.getAnotherString() %>
</asp:Content>
Do you have any suggestions ?
Thanks in advance
You are thinking that the master page is read first, but in the page life cycle, the master page is read after the Page Request, so you have to include the namespace in every page. It first looks in the current page and if it does not find it at the compile time, you will get error.
When the page is fetched, the # Page directive is read. If the directive references a master page, the master page is read as well. If this is the first time the pages have been requested, both pages are compiled.
Read from the End of the page Run-time Behavior of Master Pages
Note that the master page becomes a part of the content page. In effect, the master page acts in much the same way a user control acts — as a child of the content page and as a container within that page.
When I installed ASP.NET MVC RC2, I noticed that the template had changed from RC1. Now, all new views have the header placeholder after the main content place holder. Why is this? It seems very illogical to me and it most definitely was not the case with RC1. I googled but couldn't find any reasoning for this change. Do you know of any?
Example:
<%# Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2>Rules</h2>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
</asp:Content>
Note how the placeholder with ContentPlaceHolderID of "head" is at the bottom? Weird...
I can't say I noticed it when I upgraded, but it shouldn't matter. The two <asp:Content> sections get mapped by the ID property to their places as defined in Site.master.
Definitely check the order in Site.master, but it should be fine.
If you want to change this, you can look into the T4 template your views are using. Check out:
t4-templates-in-asp.net-mvc
t4-templates-a-quick-start-guide-for-asp-net-mvc-developers
overriding-global-t4-templates-in-asp-net-mvc-project-with-per-project-templates