[英]Cannot access Public method in Web Control's Page_Load event
我想從我的.ascx
的Page_Load
事件中調用我的Public String Function(...)
方法。 函數和包含類位於與Web控件相同的代碼中。 但是我無法使用該功能。 我該如何解決這個問題?
例:
public class Controls_WebApp : System.Web.UI.UserControl, IAttributeAccessor, IUserControlDesignerAccessor
{
protected void Page_Load(object sender, EventArgs e)
{
// Call Function
}
}
public class A
{
public string Function(string path)
{
}
}
就目前而言,您將需要一個A
實例來調用該方法
using namespaceOfA;
...
string result = new A().Function("Hello world");
或者,如果該函數不依賴於A的狀態,則可以使該函數靜態( public static string Function
)
string result = A.Function("Hello world");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.