Hi,
I have a small solution that worked fine in a 2005 website project, but I needed a project file, so I decided to cenvert it to a WAP. But now I have a very annoying problem.
The error I get is the infamous CS0030 but I cant find any classes that just remotely comes close to creating this error.
I have a mastersite (right now its called "Site1"). When I try to call the one page that is using it, I get the error:
-------- error -------
Compiler Error Message: CS0030: Cannot convert type
'AMS.VOB.Virksomhedsoverblik.Site1' to 'ASP.site1_master'
Source
Error:
|
Line 150: public new ASP.site1_master Master { Line 151: get { Line 152: return ((ASP.site1_master)(base.Master)); Line 153: } Line 154: } |
------ end error -----
The consuming page is using the MasterType directive <%@ MasterType VirtualPath="~/Site1.Master" %> so that it can access members on the Site1.master by just writing Master.Someproperty.
From looking at the CS generated codesnippet above I have a suspicion that this might be part of the problem. From what I understand the CS compiler like to rename something.something to something_something, right?
My Site1.master page contains some logic to keep track of the state of some of the controls. See a copy of it below.
I tried creating a new mastersite that just contained empty simple properties to satisfy the needs of the page that uses the mastersite, and ditched all the logic. That worked fine ... so it looks like somewhere between the logic in the Site1.master.cs page and the MasterType directive I have a problem.
Can someone give me a clue as to what might be the problem??
best regards
Lars
The way I reference the master page from my kontakt.aspx.cs file is this:
protected void Page_Load(object sender, EventArgs e)
{
Master.HeaderText = "Virksomhed";
Master.XmlMenuPath = "menu/vob.xml";
Master.XsltMenuPath = "menu/menu.xslt";
if (!IsPostBack)
{
GridView1.DataSource = new LoremIpsumList();
Page.DataBind();
Cntl.LoadContact(0);
}
}
The Site1.master.cs looks like this:
------------------------------------------
using System;
using System.Collections.Generic;
using System.Data;
using System.Configuration;
using System.Collections;
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 AMS.VOB.Common.DTO;
using AMS.VOB.BusinessLayer.ServiceLayer;
using AMS.VOB.UIComponents;
using AMS.VOB.ApplicationContainer;
namespace AMS.VOB.Virksomhedsoverblik
{
public partial class Site1 : System.Web.UI.MasterPage, IQuickSearchUI
{
private QuickSearchController cntl;
public QuickSearchController Cntl
{
get
{
if (cntl == null)
{
if (Session["QuickSearchController"] != null)
{
cntl = (QuickSearchController)Session["QuickSearchController"];
cntl.Reconnect(this);
}
else
{
cntl = new QuickSearchController(this, ServiceLocator.GetQuickSearchService());
Session["QuickSearchController"] = cntl;
}
}
return cntl;
}
set
{
cntl = value;
Session["QuickSearchController"] = cntl;
}
}
public string HeaderText
{
get { return PageHeader1.HeaderText; }
set { PageHeader1.HeaderText = value; }
}
public string XmlMenuPath
{
get { return Menubar1.XmlMenuPath; }
set { Menubar1.XmlMenuPath = value; }
}
public string XsltMenuPath
{
get { return Menubar1.XsltMenuPath; }
set { Menubar1.XsltMenuPath = value; }
}
private List<CompanyListItemDTO> quickSearchList;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Disable QuickSearchResultPanel
QuickSearchResultPanel.Visible = false;
// if sessionstate contains a searchlist, use this ...
if (quickSearchList == null && Session["quickSearchList"] != null)
{
quickSearchList = (List<CompanyListItemDTO>)Session["quickSearchList"];
BindSearchList();
}
}
}
protected void LoadSelectedCompany()
{
if (QuickSearchList.SelectedValue != "")
{
Session["QuickSearchListSelectedValue"] = QuickSearchList.SelectedValue;
Response.BufferOutput = true;
Response.Redirect("~/Virksomhed.aspx?" + QuickSearchList.SelectedValue);
}
}
protected void QuickSearchList_SelectedIndexChanged(object sender, EventArgs e)
{
LoadSelectedCompany();
}
protected void QuickSearchNext_Click(object sender, ImageClickEventArgs e)
{
if (QuickSearchList.SelectedIndex < QuickSearchList.Items.Count - 1)
{
QuickSearchList.SelectedIndex = QuickSearchList.SelectedIndex + 1;
LoadSelectedCompany();
}
}
protected void QuickSearchPrev_Click(object sender, ImageClickEventArgs e)
{
if (QuickSearchList.SelectedIndex > 0)
{
QuickSearchList.SelectedIndex = QuickSearchList.SelectedIndex - 1;
LoadSelectedCompany();
}
}
protected void QuickSearchButton_Click(object sender, EventArgs e)
{
// Clear old errormessage
QuickSearchError.Visible = false;
// Check that searchcriteria is entered
if (QuickSearchText.Text == "")
{
// Set errormessage
QuickSearchError.Text = "Udfyld s?gekriterie !";
QuickSearchError.Visible = true;
// Disable QuickSearchResultPanel
QuickSearchResultPanel.Visible = false;
}
else
{
IQuickSearchService svc = ServiceLocator.GetQuickSearchService();
// Perform search
if (QuickSearchTypeCVR.Checked)
{
quickSearchList = svc.CompanySearchByCVR(QuickSearchText.Text);
}
if (QuickSearchTypePhone.Checked)
{
quickSearchList = svc.CompanySearchByPhone(QuickSearchText.Text);
}
if (QuickSearchTypeName.Checked)
{
quickSearchList = svc.CompanySearchByName(QuickSearchText.Text);
}
Session["quickSearchList"] = quickSearchList;
Session["QuickSearchListSelectedValue"] = null;
if (quickSearchList.Count == 0)
{
// Set errormessage
QuickSearchError.Text = "Ingen virksomheder fundet !";
QuickSearchError.Visible = true;
QuickSearchResultPanel.Visible = false;
}
else
{
// Clear Searchtext
QuickSearchText.Text = "";
BindSearchList();
// Load top entry
Response.BufferOutput = true;
Response.Redirect("~/Virksomhed.aspx?" + quickSearchList[0].ValueString);
}
}
}
protected void BindSearchList()
{
if (quickSearchList.Count > 1)
{
// Setup QuickSearchResultPanel
QuickSearchResultPanel.Visible = true;
// Populate Combobox
QuickSearchList.DataSource = quickSearchList;
QuickSearchList.DataTextField = "TextString";
QuickSearchList.DataValueField = "ValueString";
QuickSearchList.DataBind();
// Set previously selected item
if (Session["QuickSearchListSelectedValue"] != null)
{
QuickSearchList.SelectedValue = (string)Session["QuickSearchListSelectedValue"];
}
else
{
QuickSearchList.SelectedIndex = 0;
}
// Set Counters
QuickSearchIndex.Text = System.Convert.ToString(QuickSearchList.SelectedIndex + 1);
QuickSearchCount.Text = QuickSearchList.Items.Count.ToString();
}
else
{
// Disable QuickSearchResultPanel
QuickSearchResultPanel.Visible = false;
}
}
public void ReBind()
{
throw new Exception("The method or operation is not implemented.");
}
public void QuickSearchCVR(string cvrNumber)
{
// Perform search
IQuickSearchService svc = ServiceLocator.GetQuickSearchService();
quickSearchList = svc.CompanySearchByCVR(cvrNumber);
Session["quickSearchList"] = quickSearchList;
Session["QuickSearchListSelectedValue"] = null;
if (quickSearchList.Count == 0)
{
// Set errormessage
QuickSearchError.Text = "Ingen virksomheder fundet !";
QuickSearchError.Visible = true;
QuickSearchResultPanel.Visible = false;
}
else
{
// Clear Searchtext
QuickSearchText.Text = "";
BindSearchList();
// Load top entry
Response.BufferOutput = true;
Response.Redirect("~/Virksomhed.aspx?" + quickSearchList[0].ValueString);
}
}
}
}