Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Help on on weird error.

Posted on 2009-07-12
4
388 Views
Last Modified: 2012-05-07
Server Error in '/PaidTimeOffUI' Application.
--------------------------------------------------------------------------------

Unable to cast object of type 'ASP.default2_aspx' to type 'BasePage'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Unable to cast object of type 'ASP.default2_aspx' to type 'BasePage'.

Source Error:


Line 17:     protected void Page_Load(object sender, EventArgs e)
Line 18:     {
Line 19:         ENTUserAccountEO currentUser = ((BasePage)Page).CurrentUser;
Line 20:
Line 21:         //Set the top menu properties
 

Source File: d:\inetpub\wwwroot\PaidTimeOffSolution\PaidTimeOffUI\PaidTimeOff.master.cs    Line: 19

Stack Trace:


[InvalidCastException: Unable to cast object of type 'ASP.default2_aspx' to type 'BasePage'.]
   PaidTimeOff.Page_Load(Object sender, EventArgs e) in d:\inetpub\wwwroot\PaidTimeOffSolution\PaidTimeOffUI\PaidTimeOff.master.cs:19
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

 

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using V2.PaidTimeOffBLL.Framework;
 
public partial class PaidTimeOff : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ENTUserAccountEO currentUser = ((BasePage)Page).CurrentUser;
 
        //Set the top menu properties
        MenuTabs1.MenuItems = Globals.GetMenuItems(this.Cache);        
        MenuTabs1.RootPath = BasePage.RootPath(Context);
        MenuTabs1.CurrentMenuItemName = ((BasePage)Page).MenuItemName();
        MenuTabs1.Roles = Globals.GetRoles(this.Cache);
        MenuTabs1.UserAccount = currentUser;
 
        //Set the side menu properties
        MenuTree1.MenuItems = Globals.GetMenuItems(this.Cache);        
        MenuTree1.RootPath = BasePage.RootPath(Context);
        MenuTree1.CurrentMenuItemName = ((BasePage)Page).MenuItemName();
        MenuTree1.Roles = Globals.GetRoles(this.Cache);
        MenuTree1.UserAccount = currentUser;
        
        lblCurrentUser.Text = Page.User.Identity.Name;
        lblCurrentDateTime.Text = DateTime.Now.ToString();
 
        //Set the version
        lblVersion.Text = ConfigurationManager.AppSettings["version"].ToString();
    }
}
===============================================================
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="PaidTimeOff.master.cs" Inherits="PaidTimeOff" %>
 
<%@ Register Assembly="V2.FrameworkControls" Namespace="V2.FrameworkControls" TagPrefix="cc1" %>
 
<!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 runat="server">
    <title>Untitled Page</title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
    <link href="PaidTimeOff.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <table width="100%" id="mainContainer" class="mainContainer">
        <tr>
            <td>
                <table width="100%">
                    <tr>
                        <td>
                            <asp:Image ID="Image1" runat="server" ImageUrl="~/images/V2Blue.gif"/>
                        </td>
                        <td class="title">
                            <asp:Label ID="lblHeader" runat="server" Text="Human Resources"></asp:Label><br />                            
                            <asp:Label ID="lblSubHeader" runat="server" Text="Paid Time Off"></asp:Label>
                        </td>        
                        <td class="user">
                            <asp:Label ID="Label1" runat="server" Text="Current User: "></asp:Label>
                            <asp:Label ID="lblCurrentUser" runat="server" Text=""></asp:Label><br />
                            <asp:Label ID="lblCurrentDateTime" runat="server" Text=""></asp:Label>
                        </td>  
                    </tr>
                </table>      
            </td>
        </tr>
        <tr>        
            <td>
                <cc1:MenuTabs ID="MenuTabs1" runat="server" />            
            </td>
        </tr>    
        <tr>
            <td valign="top">
                <table>
                    <tr valign="top">
                        <td class="sideMenu">
                            <cc1:MenuTree ID="MenuTree1" runat="server" />                
                        </td>
                        <td class="content">
                            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                            Content
                            </asp:ContentPlaceHolder>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr class="footer">
            <td>
                <asp:Label ID="lblCopyright" runat="server">Copyright &copy 2008 Vince Varallo & Wrox Press | </asp:Label><asp:Label ID="lblVersion" runat="server"></asp:Label>                
            </td>
        </tr>    
    </table>
    </form>
</body>
</html>

Open in new window

0
Comment
Question by:mathieu_cupryk
  • 2
4 Comments
 
LVL 15

Expert Comment

by:jinal
ID: 24833752
Can you please put default2.aspx.cs code over here . If not possible then some part of that code.
0
 
LVL 15

Expert Comment

by:jinal
ID: 24833775
As per my thiking you created your own BasePage Class and you create default2.aspx.cs .

This class sholdbe inherited from BasePage class instead System.Web.UI.Page class.


0
 

Author Comment

by:mathieu_cupryk
ID: 24835666
<%@ Page Language="C#" MasterPageFile="~/PaidTimeOffEditGrid.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" Title="Untitled Page" %>
<%@ MasterType virtualPath="~/PaidTimeOffEditGrid.master"%>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder3" Runat="Server">
</asp:Content>
-------------------------------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Master.AddButton_Click += new PaidTimeOffEditGrid.ButtonClickedHandler(Master_AddButton_Click);
    }

    void Master_AddButton_Click(object sender, EventArgs e)
    {
        throw new NotImplementedException();
    }        
}
---------------------------------------------------------

I  got this from the a book wrox.
0
 
LVL 2

Accepted Solution

by:
nathanbaker earned 500 total points
ID: 24845733
You have references to BasePage in your MasterPage. Where is that defined, Do you have a BasePage Class within your App_Code?

I think you possibly need to change Line 15 in your masterpage.cs, so you extend the BasePage Class

change

public partial class PaidTimeOff : System.Web.UI.MasterPage

to

public partial class PaidTimeOff : BasePage
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Javascript to set controls visibility 5 48
Function after success of Jquery/AJAX action 9 27
Add a Condition in ASP Repeater 6 33
asp Google Map 2 24
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question