我的所有的Page都是继承自一个Abstract的基页面(BasePage.aspx)。可是继承了以后运行一次以后页面就不能进入Designer状态了,只能够看到页面的Asp.net代码。提示如下(由于是日语的,因此只能是一个意思的翻译):Web Form设计窗口不能读取,以下的错误修正后请再读入。Abstract 型请确认该WebForm使用的所有class都在project内编译(build)或者被引用。
详细情况,点击Help按钮。
详细情况,点击Help按钮。
解决方案 »
- 有一个需求,需要循环根据ID添加的方法
- 在线跪求大神解救啊 ASP.NET连接数据库的问题
- .net发邮件到outlook接收到的内容中文有乱码,怎么解决?
- 什么叫页面执行速度 喝什么有关?
- 如何在GridView取值>>>>>>>>>>>??????????????????????
- =====求助!ASP.NET如何在Windows2003下释放Excel进程=====
- 怎样从数据库中取出image(blob)字段,然后付给image控件?
- 在项目里新建个文件夹,可使在里面添加的web窗体显示出现错误?
- 请问如何计算页面上有多少个控件呀。
- 我的数据库怎么连接不上呢?请大家帮忙!
- 水晶报表求救:工资报表中如何动态控制列的位置
- 求解一个简单的正则表达式
----
我目前的项目也是这样做的,没问题,可能是你的BasePage类没写好,愿意的话贴一下代码
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Web.UI;
using System.Web.UI.WebControls;
abstract public class BasePage : System.Web.UI.Page { public NameValueCollection InputParameter {
get {
return (NameValueCollection)ViewState["InputParameter"];
}
set {
ViewState["InputParameter"] = value;
}
}
override protected void OnInit(EventArgs e) {
this.Load += new System.EventHandler(this.Page_Load);
this.Error += new System.EventHandler(this.Page_Error);
this.SetEventHandler();
base.OnInit(e);
this.InitPage();
}
protected void Page_Load(object sender, System.EventArgs e) {
if(this.IsPostBack) {
this.ConvertTextBox(this);
this.PostBack();
} else {
if(this.Context.Handler.GetType().Equals(this.GetType())
&& this.IsStartPage == false) {
throw new PageException("不正なページにアクセスしました。","W00001",false);
} else {
if(this.Context.Items.Contains("FormParameter")) {
this.InputParameter = (NameValueCollection)this.Context.Items["FormParameter"];
this.FirstAccess(this.InputParameter);
} else {
this.FirstAccess();
}
}
}
} protected void Page_Error(object sender,System.EventArgs e){
}
protected void Transfer(string path,NameValueCollection formParam) {
if(formParam != null) {
this.Context.Items.Add("FormParameter",formParam);
}
Server.Transfer(path);
}
private void ConvertTextBox(Control con) {
if(con.HasControls()){
IEnumerator controlEnum = con.Controls.GetEnumerator();
while(controlEnum.MoveNext()) {
ConvertTextBox((Control)controlEnum.Current);
}
} else {
if(con is TextBox) {
((TextBox)con).Text = ((TextBox)con).Text.Trim();
((TextBox)con).Text = ((TextBox)con).Text.Replace("'",string.Empty);
((TextBox)con).Text = Server.HtmlEncode(((TextBox)con).Text);
}
}
}
virtual protected void SetEventHandler(){}
virtual protected void InitPage(){} virtual protected void FirstAccess(){}
virtual protected void FirstAccess(NameValueCollection param){} virtual protected void PostBack(){}
abstract protected bool IsStartPage{get;} }
}
1、页面基类应该是BasePage.cs 文件而不是BasePage.aspx文件。
2、页面的直接基类不能是抽象类,根据你的代码分析,你的这个抽象基类文件定义的没错,但是页面不是直接从这个基类继承,我估计在此之外还定义了的一实体类,该实体类继承于该抽象基类,你们的web 页面再继承于实体类,这样运行起来就没有问题了。