开发者

add a custom base class for web forms

开发者 https://www.devze.com 2022-12-16 08:50 出处:网络
I want to add a custom base class for all of my web form开发者_如何学Gos. I created a \"App_code\" folder in my asp.net web project and add a simple base page class like this:

I want to add a custom base class for all of my web form开发者_如何学Gos. 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();
        }
    }
}

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 
    {
    }
}

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:

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消