且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么我不能在asp.net网站上使用局部类?

更新时间:2023-02-25 20:23:46

您需要声明测试()方法主叫侧。使得它公共是可能的,但似乎没有一个很好的主意。

You need to declare the Test() method on the calling side. Making it public may be possible but does not seem a very good idea.

public partial class TestPartial : System.Web.UI.Page
{    
    partial void Test(); // add this line

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


public partial class TestPartial : System.Web.UI.Page
{
    partial void Test()  
    {
         // executed from Page_Load
    }
}