The problem that i'm having is that i made a master page like i always do. Then i add a views folder and add a web form using master page. But the design from the master page isn't showing on newly made web form.
<%# Page Title="Home - " Language="C#" MasterPageFile="~/App_Themes/Theme/shop.Master" AutoEventWireup="true" CodeBehind="home.aspx.cs" Inherits="Shop.Views.home" %>
You need to check "set masterpage" when you are adding a new webform in visual studio.
Related
I am programming an app that has some sections in WebForms and some in MVC. I have a Webform.master and a Site.Master. When using the Html class, My Webform.master in visual studio says "The name html does not exist in the current context." but I don't get that error in site.master file, and html is used many times there.
Both the site.master and webform.master are in the views/shared directory.
EDIT: my purpose is to render a partial view in webforms. I'm unable to do that because html is not recognized in webform.master. If there's an alternate way to render a partial view, I'd use that if possible.
This is the Webform.master.
<%# Master
Language="C#"
MasterPageFile="~/Views/Shared/Root.Master"
AutoEventWireup="true"
CodeBehind="Webform.master.cs"
Inherits="JCIMS_MVC2_EF.WebUI.Views.Shared.Webform"
%>
<%# Register src="SupportPartial.ascx" tagname="SupportPartial" tagprefix="uc1" %>
This is the Site.master.
<%# Master Language="C#" MasterPageFile="~/Views/Shared/Root.Master" Inherits="System.Web.Mvc.ViewMasterPage" %>
The Html methods are all part of the HtmlHelper class which is a feature of MVC.
The first line of site.Master is telling your page to inherit from System.Web.Mvc.ViewMasterPage which will give you access to the MVC namespace and the HtmlHelper you're looking for.
<%# Master Language="C#" MasterPageFile="~/Views/Shared/Root.Master" Inherits="System.Web.Mvc.ViewMasterPage" %>
Your Webform.master page inherits from JCIMS_MVC2_EF.WebUI.Views.Shared.Webform as you can see from the first line. So you will not be able to use the HtmlHelper here.
<%# Master
Language="C#"
MasterPageFile="~/Views/Shared/Root.Master"
AutoEventWireup="true"
CodeBehind="Webform.master.cs"
Inherits="JCIMS_MVC2_EF.WebUI.Views.Shared.Webform"
%>
In Sitefinity - the page controls section I created a new tool and linked it up to the user control. But when I try and add that control to the page I am getting an error?
Is there a step I am missing?
UserControl
Control Language="C#" AutoEventWireup="true" CodeBehind="TransparencyControl.ascx.cs" Inherits="SitefinityWebApp.transparency.TransparencyControl" %>
<%# Register TagPrefix="ucTransparency" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<asp:Xml ID="XmlForm" runat="server"></asp:Xml>
PageControl
PageControl tool linked to ascx page
You need to set the path to the user control (ascx) not in the Controller CLR Type field, but in Control CLR Type or Virtual Path field.
So, just cut it from the former field and paste it in the latter field and you should be fine.
Hi I'm learning a bit of webforms for a sharepoint 2010 module I'm helping with.
I've got a background with razor and enjoy inheriting templates and then using parameters set in the controller to influence the layout.
So in my system I've got a similar setup.
Index.aspx with
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="CESA19Template.Layouts.CESA19Template.Index" MasterPageFile="ValidationTemplate.master" %>
ValidationTemplate.master with
<%# Master Language="C#" MasterPageFile="../Template/Template.master" AutoEventWireup="true" %>
and the master with
<%# Master Language="C#" %>
I would like to add a parameter into the .cs behind ValidationTemplate (ValidationTemplate.master.cs) and then use that in the template as well as have my Index.aspx page change the parameter.
I've tried loads of CodeBehind and all sorts can someone help me, or isn't this possible and needs another way? (maybe a include)
I managed to solve this - basically you need to get the public key from the file behind it and then this works.
<%# Master Language="C#" MasterPageFile="../Template/Template.master" AutoEventWireup="true" Inherits="CESA19Template.Layouts.CESA19Template.ValidationTemplate,CESA19Template,Version=1.0.0.0, Culture=neutral, PublicKeyToken=68cf004eb48f0fd4"
I guess this is probably sharepoint 2010 being a bit daft.
I have two pages I want to exclude them from the sitemaster so I can add a check for the session in the sitemaster. I want to exclude them because I want that the 401.aspx page and another page can be accessed by anyone. But the rest should be checked for and authenticated.
Is this possible, and what is the best solution to do this?
Just don't add a MasterPageFile="~/Master.master" statement to your pages (or reference another MasterPage here)
Default:
<%# Page Language="C#" MasterPageFile="~/Master.master" [...] %>
"Special" pages:
<%# Page Language="C#" MasterPageFile="~/AnotherMasterPage.master" [...] %>
Without master:
<%# Page Language="C#" [...] %>
If i understood your question your problem is how to handle errors and redirect to specific files when that happens. This may help http://www.asp.net/hosting/tutorials/displaying-a-custom-error-page-cs and http://msdn.microsoft.com/en-us/library/aa479319.aspx
But if your problem is how to remove master pages from a specific file , you can simply remove it's refrence from your aspx file. remove the MasterPageFile="/Master/default.master"
from your <%# Page Language="C#" ...%>
Hope this helps.
I've just begun experimenting with nested masters in MVC2. I'm not quite sure why I am getting this error.
Parser Error Message: Could not load type 'MySite.Views.Shared.Master'.
I used the add item wizard, created Master.master, and selected it's master to be Site.Master. In one of my views I changed the MasterPageFile from Site.Master to Master.master. I haven't changed any contents. What have I gotten wrong?
It sounds like you've added a Master Page and not a MVC Master Page. You need to make sure that both of your master pages inherit from System.Web.Mvc.ViewMasterPage.
So your master page directives should look like this:
<%# Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
AND
<%# Master MasterPageFile="~/Views/Shared/Site.Master" Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
HTHs,
Charles