我在Web表單應用程序中有一個靜態頁面方法,我想從它調用私有類級別變量的方法,如下所示。我使用jQuery來調用頁面方法。從PageMethods調用業務邏輯層方法
private readonly ICatalogBLL _catalogBLL = new CatalogBLL();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
_catalogBLL.GetSomething();
}
}
[WebMethod]
public static UpdateSomething(int i)
{
//Want to do as below. But can't call it from a static method.
_catalogBLL.UpdateSomething();
}
UPDATE
如果我把它由約翰·桑德斯說,不會用它來從不同的用戶請求相同的情況下,因爲它是一個靜態方法中?
你可以只是過客'userId' ... – 2010-07-12 06:34:09
沒有意義在JavaScript中暴露用戶id用它爲不同的用戶。這將是危險的,因爲任何人都可以通過傳遞隨機userIds – IsmailS 2010-07-12 06:46:35
來激發JavaScript你誤解了我告訴我在網絡方法中傳遞它的點,而不是在JavaScript中... – 2010-07-12 07:11:13