通过本文主要向大家介绍了用juery的ajax方法调用aspx.cs页面中的webmethod方法示例等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
首先在 aspx.cs文件里建一个公开的静态方法,然后加上WebMethod属性。
如:
[WebMethod]
public static string GetUserName()
{
//......
}
如果要在这个方法里操作session,那还得将WebMethod的EnableSession 属性设为true 。即:
[WebMethod(EnableSession = true)]//或[WebMethod(true)]
public static string GetUserName()
{
//......
}
然后我们就写ajax程序来访问这个程序,我们就用jQuery吧。
</div> </div>
如:
[WebMethod]
public static string GetUserName()
{
//......
}
如果要在这个方法里操作session,那还得将WebMethod的EnableSession 属性设为true 。即:
[WebMethod(EnableSession = true)]//或[WebMethod(true)]
public static string GetUserName()
{
//......
}
然后我们就写ajax程序来访问这个程序,我们就用jQuery吧。
</div> </div>