MasterType Directive Not Implied After Setting Page MasterPageFIle?
Jan 28, 2010
The docs for @MasterType have this example.
<%@ Page masterPageFile="~/MasterPage.master"%>
<%@ MasterType virtualPath="~/MasterPage.master"%>
Why is @MasterType even needed? Couldn't the compiler automatically take the same actions based solely on @Page masterPageFile? When would you not want to use both?
View 1 Replies
Similar Messages:
Aug 17, 2010
I am working with a third party asp.net application that uses master pages and nested master pages. My needs are to dynamically set the master page files for each page(.aspx). The application by default sets the master page file in the strongly typed @Page directive for each page. I don't want to change the strongly typed directive on each page (over 50 pages) because I am lazy and I want to minimize conflicts with future upgrades.
protected override void OnPreInit(EventArgs e)
{
this.MasterPageFile = "~/MasterPages/MyMaster.master";
View 3 Replies
Oct 10, 2010
I'm studying up for a Microsoft Certification exam, and some of the wording for the 'content' in the examn confused me. In the MS exam website, under Developing Web Form Pages, it says in regard to the content on the exam...
This objective may include but is not limited to: page directives such as ViewState, request validation, event validation, MasterPageFile; ClientIDMode;
I was under the impression that a page directive referred to the @Page keyword, and the associated values defined in the @Page section were attributes/properties. But the wording of the exam content almost implies that the attributes/properties of the @Page keyword are directives.
View 2 Replies
Mar 13, 2010
I am receiving a Parser Error with all my pages in a particular folder:
Parser Error Message:
The file '/railroad/freightcars/covered_hopper/MasterFiles/Freightcars.master' does not exist.
Line 1: <%@ Page Title="Freight Car Photos - CP Covered hoppers - CoveredHopperPhotos.com" Language="C#"
MasterPageFile="~/MasterFiles/Freightcars.master" AutoEventWireup="true" CodeFile="cprail.aspx.cs" Inherits="railroad_freightcars_covered_hoppers_cprail" %>
It seems like the ~ is not resolving; none of my .aspx pages in this folder work. All my pages in several other folders work fine.
I had this problem with another folder when i first published pages to a folder named covered_hoppers. Since i couldn't figure out the problem, i renamed the folder to covered_hopper and re-published.. all worked fine for a couple of months until yesterday. Now i am having the same problem. No problems on my local copy; never had this error with any other folder in my site.
View 5 Replies
Apr 11, 2010
I am working on an MVC site using NHaml for the view engine.
I have a page that needs to submit HTML code as a form value and am getting the System.Web.HttpRequestValidationException thrown at me.
I want to specify the <%@ Page validateRequest="false" %> so that this page will allow this data to be submitted but am unsure on how to do this with NHaml generating the pages.
The editor I was using was TinyMCE and I found that it has an option for encoding the output, that way it doesn't trigger the anti-html validation.
[URL]
View 1 Replies
Aug 10, 2010
I have been trying to find a way to declare two classes using page directive, but it seems like mvc framework doesnt support it.
I have got :
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<ContactManager.Models.contact>>" %>
which shows the list of the contacts including edit delete and create option.
What I need to declare another model class which is FileRepository.cs for uploading files on the same page. In this case the page directive should be like:
2. <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<ContactManager.Models.FileDescription>>" %>
Is there any way I can incorporate both into one as the first is coming from the database.
View 6 Replies
Feb 12, 2010
A page could have an attribute MasterType to make Page.Master to be strong-typed:
<%@ MasterType VirtualPath="~/Site.master" %>
If all my pages inherits specific class inherited System.Web.UI.Page itself, can I someway get access to this.Master property in it so I could call master page's methods?
View 1 Replies
May 14, 2010
I am having trouble with the performance of a web site... Some SQL queries are killing the server. But, as the title of this post mention, I looked at the OutputCache page directive to improve performance of the site. Although, I came across some questions regarding this directive:
1- If I have a web-user control that declares an OuputCache directive in a page that has one too, which one will "win"?
2- What's the best pratice regarding the duration ? I'd love to have a sliding window too.
View 2 Replies
Feb 19, 2010
I get a error on this line
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="FormA.aspx.vb" Inherits="_Default" %>
It says expression expected
another error is :name bind is not declared
Both the errors point to column 1 line 1
View 2 Replies
Dec 10, 2010
i designed an export to excel page that uses the following code
the data is displayed in grid view and the date format is displayed as M/d/yyyy
so i added the culture en-GB to page directive to display the date as d/M/yyyy
the date now displays correctly d/M/yyyy, and the utf-8 also display correctly in gridview.
however once i export to excel the utf-8 appears scrambled
when ever i remove the culture from page directives, names display correctly, however i face again the M/d/yyyy issue.
My question is: is there a way to display date as d/M/yyyy and at the same time reading correct utf-8
View 1 Replies
Feb 24, 2011
Is it possible to set the Inherits attribute of an ASPX Page directive to a class in an arbitrary assembly?
I need to modify an ASP.NET (1.1) application for which the source code was lost. In a new assembly (foo2.dll) I've created a replacement code-behind class that derives from the original class in the site's code-behind assembly (foo.dll). It seems easy enough to set the Inherits attribute of the Page directive to the new class name, but when I do that the web server gives me Could not load type 'Foo2.checkout2'. I am referencing the new assembly in the <assemblies> section of Web.config.
I don't see anything in the documentation to indicate that this scenario is unsupported, but I'm not certain that it is, either.
Original
<%@ Page Inherits="Foo.checkout" language="c#" Codebehind="checkout.aspx.cs" AutoEventWireup="false" %>
New
<%@ Page Inherits="Foo2.checkout2" CodeFile="checkout2.aspx.cs" CodeFileBaseClass="Foo.checkout" language="c#" Codebehind="checkout.aspx.cs" AutoEventWireup="false" %>
View 1 Replies
Jan 27, 2010
OK, so I'm trying to create a template item from a web form.
I have referenced this article: [URL] and it exports the template and installs it fine.
When you try and use the template item within a project though it leaves the inherits="_Default" in the page directive like shown below:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FormTemplateDev.aspx.cs" Inherits="_Default" %>
So it thinks all the new template items use the original form name pre-template generation. This is an issue in the code behind too as shown here:
public partial class _Default : System.Web.UI.Page
I have seen example of passing paramater strings through but havent managed to get anything to compile. I found something like below:
public partial class $safeitemname$ : System.Web.UI.Page
This was the link to the list of available template parameters i found:
Project Template Parameters
View 1 Replies
Jan 12, 2011
As that title says my aspx page shows a compile error on the @Page directive that says "ASP.NET runtime error: Cannot load file or Assembly 'Microsoft.SqlServer.BatchParser' or one of it's dependencies". The project compiles with our error and it runs with no problem. The only real problem that this causes it that the intellisense for anything other than simple HTML is broken so I can't type asp:Controlname and have intellisense show me a the list of items or properties in a control. I get a green squiggly line under all the asp tags saying "Unrecognized tag prefix or device filter 'asp'". This project doesn't directly use SQL SMO but it does reference a project that does. However, I removed that reference and the problem still doesn't go away. I have installed on my development machine the full SQL client and for both SQL 2005 and 2008 (including the SDK) from the Developer editions of both versions. This was not a problem on VS2005 and the project compiles without error in VS2010 too.
View 1 Replies
Sep 7, 2010
I'm trying to use a MasterType TypeName to access a class with master pages. This works when I'm using .NET 2.0, VS 2005, and C#. When I try this using .NET 3.5, VS 2008 and C# I get the error:
The type or namespace name 'classA' could not be found (are you missing a using directive or an assembly reference?) and it is pointing to the Default.aspx.designer.cs
In the default.aspx I have:
<%@ Page Language="C#" MasterPageFile="...
<%@ MasterType TypeName="classA" %>
I have added a folder App_Code to my project and in that folder I have a class file "classA.cs" that contains:
Using ...
Namespace Project.App_Code
{
public class classA : System.Web.UI.MasterPage
...
The main difference that I see from where it works and where it doesn't work is that where it doesn't work it uses the namespace called Project.So I figure my problem is in the including the class classA in the namespace or properly including the namespace and / or App_Code directory in the MasterType TypeName which I don't seem to be able to figure out.
View 6 Replies
Aug 12, 2010
I'm trying to use a master page in my website. I created a page and then created the master. I then added the tag MasterPageFile="~/master". I'm guessing that I need to do something to my main page, because I've now started getting the error:
The page contains markup that is not valid when attached to a master page
My main page is as follows:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" MasterPageFile="~/my.master" %>
<!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">
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
I tried deleting the tag thinking that this might be the issue. Can anyone point me in the right direction?
View 2 Replies
Jan 21, 2011
I have a Page (index.aspx) that inherits from MasterPage (Index.Master) that inherits from another MasterPage (/template1/Website.Master). I want to be able to set the masterpagefile of Index.Master to /template2/Website.Master programmatically.
My index.aspx is basically a placeholder file (I have multiple directories with the same placeholder files, and I don't want to have to update every folder if i make a change to 1 file). All the website content is located in Index.Master. The layout of the website is in Website.Master. I want to be able to change the layout based on a selection stored in a local xml file in each of the folders.
I understand I can change the Page PreInit on the aspx page easy enough, but I don't want to change that. It has to link to the index.master.
Index.Master doesn't have a PreInit because it's a masterpage, not a page...
View 2 Replies
Feb 5, 2010
with my master pages. They have such inheritance order:MainMaster1.Master can be nested by Nested1.Master, Nested2.Master, etc.
At the same time MainMaster can be duplicated and have working copies like MainMaster2, MainMaster3, etc.Advise please how can I dynamically change the MasterPageFile of my Nested1, Nested2, etc. pages so that they can easily switch between MainMasters if needed?
View 2 Replies
Aug 16, 2010
Is it possible to set MasterPageFile name property dynamically?
<%@ Page Language="C#" MasterPageFile="~/xxxx/OuterMasterPage1.master" AutoEventWireup="true" CodeFile="xxxx.aspx.cs" Inherits="xxxx.cs" %>
Can we set "~/xxxx" path dynamically?
View 2 Replies
Jan 27, 2010
I have problem when I use "Web Deployment" project to deploy web site by VS.NET 2005. Although, file .aspx does not contain theme in section page directive, web deployment add theme as same as value of Web.config automatically when deploy project.
View 3 Replies
Nov 24, 2010
in direct regards to my last question.
my css files are located in the app_themes directory.
so im not the one adding the reference to them in the master page.
so how can i implement the solution they gave me in my last question?
View 1 Replies
Nov 18, 2010
I would like to parse QueryString and put the ID value to the ImgUrl path, I am trying this code:
<asp:Image ID="imgImageNormal" runat="server" ImageUrl='<%# string.Format("ImageHandler.ashx?ID={0}",Request.QueryString["ID"].ToString()) %>'/>
But the produced result is none. I am not getting any error message but after viewing the source of the page, this is the output for the image:
<img id="ctl00_ContentPlaceHolder1_imgImageNormal" src="" style="border-width:0px;" />
What am I doing wrong?
View 1 Replies
Jan 29, 2010
I inherited a really weird ASP.NET application where every .aspx page is basically a WebControl that acts as a surface for every other control that page is supposed to render/display.
One such page has a DropDownList -- I wanted a very simple thing that people do every day, namely to cause a postback when user changes a selection in it. I thought all I had to was set dropDownList.AutoPostBack = true, but after the page is rendered, when I see the generated HTML, I notice that there is no "onchange = __doPostBack(...)" code for the dropdownlist. Consequently selection changes don't do anything. Before I spend too much time digging into this, is there something obvious I am missing?
View 4 Replies
Jul 18, 2012
I have 2 DataGrid in a single page.
First DataGrid contain 2 page and 10 records per page
Second DataGrid contain 5 page and 10 records per page
When i click 3rd page of second DataGridthe following error occur
"Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount."
public partial class Admin_Over_all_report : System.Web.UI.Page {
Dataconnection dc = new Dataconnection();
protected void Page_Load(object sender, EventArgs e) {
if (IsPostBack == false) {
bind();
[Code] ....
View 1 Replies
Mar 8, 2010
It is possible to create a constant like this:
[URL]
<%@ Page CompilerOptions="/d:QUUX" %>
How to create multiple constants ?
View 1 Replies
Mar 10, 2011
I am loading .aspx and .ascx files as StreamReader.
I want each file to register it's javascript and stylesheet dependencies in some declaration like a <%@ ClientDependency path="~/Scripts/jquery-1.4.1.min.js" %>.
Is there an existing convention for doing such a thing? I don't need an implementation, but I don't want to create a new syntax if there is already a way to do it.
Also, what are the guidelines for custom <%@ blocks in ASP.NET?
View 3 Replies