求.net下ajax操作Application对象(Application内的数据为自定义类对象)的方法
代码如下:
global.asax中
void Application_Start(object sender, EventArgs e)
{
// 在应用程序启动时运行的代码
Game game = new Game();//该类我已经在其他类文件中定义好
Application["Game"] = game ;
}
login.aspx中
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="login" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>登录成功</title>
<script language="javascript" type="text/javascript">
function ZhunBei()
{
login.ZhunBei(<%=Application["Game"] %>);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div><input type="button" value="准备" onclick="ZhunBei()" id="Button1" /></div>
</form>
</body>
</html>
long.aspx.cs中
[AjaxPro.AjaxMethod]
public void ZhunBei(object _game)
{
Game tempGame = (Game)_game;
}
系统java脚本的错:Game对象未定义。
曾经在网上听朋友们说过Ajax虽然可以操作Application对象,但如果 Aplication对象中的内容是自定义类的实例对象的话则无法处理。不知道各位有什么办法 ,期待中。。。。