Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to cast object of type 'ASP.xsd_master' to type 'xSD'.

Status
Not open for further replies.

j0em0mma

Programmer
Jul 31, 2003
131
US
I got this error randomly once every few days for awhile. Once I stopped debugging, it would run again fine. Over the past few days, the project would only rebuild if I deleted the temporary files in the following directory:
Code:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\website

I decided to delete this folder and reboot. Now the project will not build no matter what I do.

error is on this line in the page calling the xSD.Master:

Code:
xSD mxSD = (xSD)Page.Master;

in my defaut.aspx.cs:

Code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Text;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
    public int cbCount = 5;
    public ListBox lb;

    // Define method that processes the callbacks on server.
    public void RaiseCallbackEvent(String eventArgument)
    {
        //cbCount = Convert.ToInt32(eventArgument) + 1;
        //ListBox1.SelectedValue = "3";
    }

    // Define method that returns callback result.
    public string GetCallbackResult()
    {
        return cbCount.ToString();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        xSD mxSD = (xSD)Page.Master;
        mxSD.EnableOverflow = true;
        mxSD.IsRMenuVisible = true;
        mxSD.IsLMenuVisible = true;
        mxSD.PageTitle = "Home";
    }
}

below is the entire master page:

Code:
using ASP;
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Text;
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;

public partial class xSD : System.Web.UI.MasterPage
{
    //private StringBuilder _OnLoadClientScript;
    //private StringBuilder _OnResizeClientScript;
    //private StringBuilder _ScrollingDivs;

    protected void Page_Load(object sender, EventArgs e)
    {
        //formProperties();
    }

    //private void formProperties()
    //{
    //    _ScrollingDivs.Append("resizeable_DIV");
    //}

    //public void addOnLoadClientScript(string ScriptContent)
    //{
    //    _OnLoadClientScript.Append(ScriptContent);
    //}

    //public void addOnResizeClientScript(string ScriptContent)
    //{
    //    _OnResizeClientScript.Append(ScriptContent);
    //}

    //public void addScrollingDivs(string ScrollingDivID)
    //{
    //    if (_ScrollingDivs.Length = 0)
    //    {
    //        _ScrollingDivs.Append(ScriptContent);
    //    }
    //    else
    //    {
    //        _ScrollingDivs.Append(",");
    //        _ScrollingDivs.Append(ScriptContent);
    //    }
        
    //}


    public string PageTitle
    {
        set
        {
            CurPageTitle.PageTitle = value;
        }
        get { return CurPageTitle.PageTitle; }

    }

    //private string onLoadScript
    //{


    //}
    //public string addClientScript(string scriptType, string clientScript)
    //{
    //    //set
    //    //{
    //    //    StringBuilder sbOnLoad = new StringBuilder();
    //    //    sbOnLoad.Append(onLoadScript);
    //    //    sbOnLoad.Append(value);
    //    //    CurPageTitle.PageTitle = value;
    //    //}
    //    //get { return CurPageTitle.PageTitle; }
    //}

    public bool IsRMenuVisible
    {
        set
        {
            if (!value)
            {
                Master_Content_rcol.Attributes["style"] = "display: none;";
            }
        }
    }

    public bool IsLMenuVisible
    {
        set
        {
            if (!value)
            {
                Master_Content_lcol.Attributes["style"] = "display: none;";
            }
        }
    }

    public bool EnableOverflow
    {
        set
        {
            if (value)
            {
                Page.ClientScript.RegisterClientScriptInclude(typeof(Page), "resizeJs", "./includes/resize.js");

                StringBuilder sb = new StringBuilder();
                sb.Append("<script language=\"javascript\">\n");
                sb.Append("    window.onload = function(){guiSizeChange('load');}\n");
                sb.Append("    window.onresize = function(){guiSizeChange('resize');}\n");
                sb.Append("</script>\n");
                Page.ClientScript.RegisterStartupScript(typeof(Page), "scr_resize", sb.ToString(),false);
                
                

                //Page.RegisterStartupScript("scr_resize", sb.ToString());
                //RegisterStartupScript("scr_Resize", sb.ToString());
            }
        }
    }
}

I am just learning c#, so not really sure how to proceed with fixing this... Any help would be greatly appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top