更新时间:2023-11-22 19:07:04
你可以这样试试
假设你有一个这样的页面WebPage1.aspx.cs
它包含一些方法
you can try like this
suppose you have a page like thisWebPage1.aspx.cs
it contains some method as
public string SomeMethod()
{
return "something";
}
您可以通过创建类的实例并访问成员来访问任何页面中的此方法
you can access this method in any page by creating an instance of the class and access the members as
WebPage1 obj = new WebPage1();
var some = obj.SomeMethod();
你也可以通过另一种方法做同样的方法,使方法为 static
注意:确保该方法对页面控件没有依赖性
检查出来:如何将一个Web表单的函数或方法调用到其他Web形式使用asp.net [ ^ ]