添加Web表单的自定义的基类 [英] add a custom base class for web forms

查看:141
本文介绍了添加Web表单的自定义的基类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要添加自定义的基类为我所有的网页表单。我在asp.net web项目创造了AP​​P_ code文件夹,并添加一个简单的基本页面类是这样的:

I want to add a custom base class for all of my web forms. I created a "App_code" folder in my asp.net web project and add a simple base page class like this:

namespace MySite.Web
{
    // base page for all the pages that need localization
    public class LocalizationPage : System.Web.UI.Page
    {
        protected override void InitializeCulture()
        {
            base.InitializeCulture();
        }
    }
}

然后我尽量让asp.net web表单,从这个基地页继承。我有这样的事情:

And then I try to let asp.net web form to inherit from this base page. I have something like this:

using MySite.Web;

namespace MySite.Public
{
    public partial class RegisterPage : LocalizationPage 
    {
    }
}

现在我遇到问题,在Visual Studio中不承认我创建了LocalizationPage类。在上述code段,LocalizationPage没有突出显示为一类。当我尝试编译,我得到了以下错误消息:

Now I run into problem where Visual Studio doesn't recognize the LocalizationPage class I created. On the above code snippet, LocalizationPage is not highlighted as a class. And when I try to compile, I got the following error message:

错误1类型或命名空间名称
  LocalizationPage'找不到
  (是否缺少using指令或
  装配
  引用?)

Error 1 The type or namespace name 'LocalizationPage' could not be found (are you missing a using directive or an assembly reference?)

请提前指点...谢谢。

Please advice...thanks in advance.

推荐答案

打开在APP_ code文件夹中的文件的属性,并检查生成操作 。将其更改为编译,以便该文件包含在编译和班会存在。

Open the properties for the file in the App_Code folder, and check the Build Action. Change it to Compile so that the file is included in the compilation, and the class will exist.

这篇关于添加Web表单的自定义的基类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆