Web Forms :: Get The Basepage Class Outside The Project / Could Not Load Type '~/Master/App_Code/BasePage<Page>'

Jun 2, 2010

I have a MasterPage project which is a class library project (it includes themes, style sheets, menus etc) and all applications use them.

I am using the BasePage concept for dynamically adding title,meta tags and descriptions. This BasePage Class inherits system.UI.Page and the aspx pages in the project inherits the BasePage class.

Now i need to move this BasePage class from my application to the Master Page Project so that all the projects/applications can reuse the same code.

I tried add the basepage.cs in the App_code folder and tried calling it in the page directive like below

<%@
Page
Language="C#"
MasterPageFile="~/Master/Layout/MasterPage.master"
AutoEventWireup="true"
CodeBehind="xxxx.aspx.cs"
CodeFile="xxxx.aspx.cs"
Inherits="xxxx"
ValidateRequest="false"
EnableEventValidation="false"
ViewStateEncryptionMode="Never"
CodeFileBaseClass="~/Master/App_Code/BasePage<Page>"
Title="Title"
Meta_Keywords="xxxx,yyyy,zzzz"
Meta_Description="This is a test" %>

But i am getting error

Could not load type '~/Master/App_Code/BasePage<Page>'.

This was working fine till the BasePage class was inside the application. But once i moved it out of the project and added it to the master page project i getting this error.

View 3 Replies


Similar Messages:

Web Forms :: Having BasePage Class Outside The Current Project/Could Not Load Type

Jun 10, 2010

We are using nested master page the master page is seperate class library project and all the other projects refer to them. We wanted to have a basepage class which load title, meta tags and keywords dynamically. It was working fine till it was inside the main project. We wanted the basepage class to be more generic and to have it reside in a single place. So i tried created a seperate class library project but i getting error "Could not load type" ..

How to have the basepage class outside the project?

View 3 Replies

Web Forms :: Setting Properties Within BasePage Class Not Working?

Jan 11, 2010

We are trying to use a BasePage class (which inherits from Page) to populate and set the Meta Keywords and Meta Description Tags. I am using masterpages and below is an example code extract... According to examples on the internet, I could then set this also via the Page Directive using the MetaKeywords and MetaDescription properties, but they do not appear.

I have tried setting the CodeFileBaseClass="MyNamespace.UI.BasePage" but this does not work either. Using debug I can see that the BasePage classes' MetaKeywords and MetaDescription properties are not being set within my content page. I can access the properties but not set them.

== BASEPAGE CLASS ==

[Code]....

== PAGE CLASS ==

[Code]....

View 3 Replies

Web Forms :: Error When Using A BasePage Along With A Master Page/ Object Reference Not Set To An Instance Of An Object

Mar 6, 2010

I'm new to programming in ASP.NET, but I'm making my way through Wrox's Beginning ASP.NET 3.5 in C# and VB.NET.

I'm at a section where I'm creating a BasePage. I successfully created a BasePage by creating a new class file in my App_Code folder called BasePage.cs with the following code:

[Code]....

If I run that code everything works out fine. The page loads and all is well. But, if I try to do the same thing to a page that uses my MasterPage.master file, I get the following error:

Object reference not set to an instance of an object.

Description:

An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Why is that? In the example code from the book (that also uses a MasterPage.master file), everything excutes and runs just fine. But in my test, I get the above error. I've tried comparing my pages to the books included source pages, but I can't find any differences.

View 1 Replies

How To Work With Master Page That Is Attached To The Page Via The Page's Basepage

Nov 2, 2010

In my ASP.Net web application, I have a base page that implements functionality that spans all pages of the web application and my web pages derive from this base page. Since there is a single master page for the entire website, I don't want to attach the master page in each of the web pages. So I attached the Master page via the basepage's OnPreInit method as follows:

protected override void OnPreInit(EventArgs e)
{
this.MasterPageFile = "~/Site.master";
base.OnPreInit(e);
}

However, when I switch to Designer view, I get the "Master Page Error"; The page has controls that require a Master Page reference, but noe is specified. Correct the problem in Code View.When I run the application, the webpage shows up correctly.What should be done so that the designer shows up correctly without having to go and set the master page explicitly in each of the web pages?

BTW, I am on Visual Studio 2010 and .Net 4.0

View 1 Replies

Assign A Hidden Field Value On Default.aspx Using BasePage Class Methods?

Nov 3, 2010

Is that possible? The reason why am doing this is because I need to parse that variable into a an JQuery function so I wanted JQuery to read that field. Can I Assign that value in base class or I have to do it within default.aspx pageload method?

View 1 Replies

C# - What's Functionality And Methods To Add "BasePage" Class

Apr 4, 2011

What cool functionality and methods do you add to your ASP.net BasePage : System.Web.UI.Page classes? Here's something I use for authentication, and I'd like to hear your opinions on this:

protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
// Authentication code omitted... Essentially same as below.
if (_RequiresAuthentication && !(IsAuthorized))
{
RespondForbidden("You do not have permissions to view this page.", UnauthorizedRedirect);
return;
}
}
// This function is overridden in each page subclass and fitted to each page's
// own authorization requirements.
// This also allows cascading authorization checks,
// e.g: User has permission to view page? No - base.IsAuthorized - Is user an admin?
protected virtual bool IsAuthorized
{
get { return true; }
}

My BasePage class contains an instance of this class:

public class StatusCodeResponse {
public StatusCodeResponse(HttpContext context) {
this._context = context;
}
/// <summary>
/// Responds with a specified status code, and if specified - transfers to a page.
/// </summary>
private void RespondStatusCode(HttpContext context, System.Net.HttpStatusCode status, string message, string transfer)
{
if (string.IsNullOrEmpty(transfer))
{
throw new HttpException((int)status, message);
}
context.Response.StatusCode = (int)status;
context.Response.StatusDescription = message;
context.Server.Transfer(transfer);
}
public void RespondForbidden(string message, string transfer)
{
RespondStatusCode(this._context, System.Net.HttpStatusCode.Forbidden, message, transfer);
}
// And a few more like these...
}

As a side note, this could be accomplished using extension methods for the HttpResponse object. And another method I find quite handy for parsing querystring int arguments:

public bool ParseId(string field, out int result)
{
return (int.TryParse(Request.QueryString[field], out result) && result > 0);
}

View 8 Replies

Web Forms :: Get A List Of All Classes That Inherit From BasePage In The Web Application?

May 13, 2010

I need to get a list of all of these webforms.

As the subject reads, how can i accomplish this ? All my webforms inherits from a class called "BasePage". It can also suffice with only getting a list of all the webforms in the application, regardless of base class since i can check inheritance later in code.

Reason i'm asking is because i'm building my menu and i'm implementing security enforced user visibility based on what pages there are in the webbapplication, and what roles each page demands, and display these to the user in the menu.

Using sitemaps are insufficient, i need to provide much more info for all the pages i have on my system.

Using this technique i can query my "PageProvider" for like:

GetAllPagesVisibibleToUser(MembershipUser user)
DoesUserHaveAccessToPage(MembershipUser user, BasePage forPage)

I'm also planning on implementing this technique on WebUserControls.

View 1 Replies

Forms Data Controls :: Access To BasePage From Ascx?

May 6, 2010

I have a basepage class which holds a bunch of properties, and specifically a context reference to entityframework

I have a standard .aspx page that inherits from the base page like so

public partial class myinterviews : BasePage

I have a standalone .ascx page, it has a grid and a datasource. This .ascx page is apart of the .aspx page that inherits from the base page. How can I reference the methods, properties from the base page from within my .ascx page?

View 1 Replies

C# - ASP.Net - Accessing My BasePage Properties From Within Markup?

Oct 22, 2010

I want to be able to extend the System.Web.UI.Page class and then easily access those properties from the Markup. I know I can do it from the codebehind, but is it possible from the Markup?

View 3 Replies

State Management :: CS0101 - Namespace '' Already Contains Definition For 'BasePage'

Jun 2, 2010

I get this error "CS0101: The namespace '<global namespace>' already contains a definition for 'BasePage'" now that I have uploaded my website to a server though before it wasn't there. It is OK when I run it locally just not from server. It refers to a theme

[Code]....

View 2 Replies

Visual Studio :: New Class File In App_Code In Vs 2010 In New Web Project Not Compiling

May 23, 2010

Best way to describe my issue with vs 2010.create a new website. create the App_Code folder. create a new class in the folder. put the line "x" in the class declaration. hit compile. And the website will compile with no errors. It's not "seeing" this new class as being part of the project best I can tell.

View 1 Replies

Configuration :: Slow Load Time After Updating Class In App_Code?

Dec 20, 2010

We have an asp.net website running on IIS 6 Windows 2003. When ever we upload a class file to the App_Code folder our whole site goes down temporarily until, what I assume, compilation is complete. Has anyone else experienced this? Any other file we upload it does not do this only our class files.

View 1 Replies

Get The URL Of The Current Page From Within A C# App_Code Class?

Oct 19, 2010

I have a logging class that, well, logs things. I would like to add the ability to automatically have the current page be logged with the messages. Is there a way to get the information I'm looking for?

View 4 Replies

Web Forms :: Define Reusable Master Page Type To Reuse Parts Of The Master Page?

Jan 5, 2011

My Project is a normal web site, not a Web Project, and I am using VS 2005.

I am trying to define common Master Page Type in app_code which has an area to display error messages and the like. Very simple.

I added the following in app_code:

[Code]....

Also, I added the following in Master Page Source Declaration:

[Code]....

Also, I added the controls tblrowErrMsg and lblErrMsg as server controls to the Master Page.

Why I am doing this ?

This will allow me to display error messages from nearly any where inside the code in code-behined, app_code, and other core Class Projects (DLL).

View 4 Replies

Cant Get Class In App_Code To Work In Code Behind Page For Simple Page?

Jun 8, 2010

just a quick question -i cant get my class in App_Code to work in my code behind page for simple .net page, some light what doing wrong?

[Code]....

View 7 Replies

Get Page Title Inside Class In App_Code Folder

May 5, 2010

I guess I might be missing something easy (or not) here. I have a class in App_Code which do some validations over Session and Request.Url, till here it's working fine. But then I need to get the actual page title. I know it's simple to get it in the page's code behind, but could I get it in a separate class like it is on my scenario?

View 8 Replies

Accessing Master Page In Custom PageBase In App_Code?

May 26, 2010

I am tring to access a custom property on my Master page in a custom PageBase that resides in the App_Code folder. I can get this to work no problem in a web app but im having trouble doing it in the website project.

PageBase:

public abstract class PageBase : ClientSidePageBase
{
public WebMessage Message
{
get

[code]...

The above sample is what is in my web application and works fine but if i try and put this in the App_Code it doesnt pick up the MasterPage class so I cant access the property.

View 1 Replies

Web Forms :: How To Load From Secondary (Derived) Master Page Controls In Page Load

Feb 25, 2010

I hv Declared two Master page one Is Base and Derived.. Base Page Load is working but when i hv written load controls in Derived Page Load Using C# it's not working..

View 3 Replies

MVC :: Could Not Load Type While Running VS2010 Project

May 23, 2010

I have had a project called Articles and the project complies fine. I have it running as a seperate site on my machine and it works like a charm under IIS7. When I start the project from VS2010 in debug mode (by pressing F5) it lands on a page that says: "Parser Error Message: Could not load type 'Articles._Default'."

I i however change the path in the browser from [URL] Home it works fine again, indicating that my routing table is bust but it was working yesterday and I did not change any route, The error page also says: "Please do not delete this file. It is used to ensure that ASP.NET MVC is activated by IIS when a user makes a "/" request to the server." That idicates to me that it went to default.aspx...right?

View 3 Replies

Configuration :: Project Build On Web Server / Parse Error : Could Not Load Type 'Namespace.PageName'

Mar 17, 2010

I have an ASP.NET 3.5 website application using C# and SQL 2005 running on a web server. Now the application has the ability to create new aspx pages with content and the relative aspx.cs and design.cs pages needed on the fly and store them in the base directory on the server. Think of it as a crued Visual Studio website on the server for admin to click a few options on a page then the new pages are created for them without the need of a web developer. This all works fine and the code is working 100% (for the moment).

My problem now is the following: When i now navigate to this newly created page i get the following error - Parse Error : Could not load type 'Namespace.PageName'

I've looked into the reasoning and microsoft say "These errors occur if the .aspx page contains a reference to a code-behind module and if the application has not been built." Which now makes sense the application does not realise that these new pages are part of its system even though i can navigate to them.How do i get the system to recognise these new pages and rebuild itself accordingly?Now i cannot rebuild the system localy then reupload to the server, this needs to be accomplished on the server by the system, because the site cannot afford to have down time everytime admin decide to add new pages.

View 3 Replies

List All Classes In Application (Including Class In App_Code And Partial Class(aspx Pages And Asmx User Controls)?

Nov 15, 2010

Is there any way to list all the class in my ASP.Net application(Including class in App_Code and Partial Class(aspx pages and asmx user controls)

View 3 Replies

Web Forms :: Type And Name Not Declared Errors In App_Code

Nov 4, 2010

I have an application which I have worked on several times, but this week I've been trying to get the application to work on a new laptop and failed. First there were was some dependency issues with some controls like the AJAX Control Toolkit and AJAX Extensions, but now that I have everything I'm still getting errors. The errors that I'm getting are only in the App_Code classes. For Example I have the following references in the web.config

<namespaces>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Specialized"/>
<add namespace="System.Configuration"/>
<add namespace="System.Text"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Web"/>............

View 11 Replies

Web Forms :: Putting Email Class In App_Code

Dec 6, 2010

I'm trying to set up a smart way to handle email in my ASP.NET Web Application Project. I created a class in my App_Code folder named "MailHelper.cs" but am having trouble invoking it in the code-behind pages. Can someone please correct me on the correct way to do this?Here's the Mail.Helper.cs file in App_Code:

[Code]....

How do I invoke this when I'm ready to fire off a message? Let's say I have a Submit_Click event and want an email to be generated:

[Code]....

View 3 Replies

Web Forms :: Calling Javascript Method During Page Load From Content While Using Master Page

Mar 30, 2010

I want to call a javascript method during page load. I am using application.master of the sharepoint server 2007 as the master page . In the content page i want to call a custom method named OnLoadFun() during loading the content page. I have written the function inside script tag in the PlaceHolderAdditionalPageHead id section of the content page.

[Code]....

How do i call the OnLoadFun method so the i is being called onload time. i tried putting window.onload=OnLoadFun surrounded by script tag within the PlaceHolderMain content section.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved