2种asp.net ajax方法如何集成
c# asp.net vs2008
第一种方式
page_load下
m_ADFCallbackFunctionString = Page.ClientScript.GetCallbackEventReference(this, "message",
"processCallbackResult", "context", "postBackError", true);
}
public void RaiseCallbackEvent(string eventargs)
{
// 将传入参数依据&分割符分到querystring变量中
Array keyValuePairs = eventargs.Split("&".ToCharArray());
NameValueCollection queryString = new NameValueCollection();
string[] keyValue;
string response = "";
if (keyValuePairs.Length > 0)
{
for (int i = 0; i < keyValuePairs.Length; i++)
{
keyValue = keyValuePairs.GetValue(i).ToString().Split("=".ToCharArray());
queryString.Add(keyValue[0], keyValue[1]);
}
}
else
{
keyValue = eventargs.Split("=".ToCharArray());
if (keyValue.Length > 0)
queryString.Add(keyValue[0], keyValue[1]);
}
// 是否进行缓存,对于属性查询图形不进行缓存
bool needCached = true;
// 针对参数中指定的ActiveType不同执行不同操作
string Condtion = queryString["Condtion"];
string eventArg = queryString["EventArg"];
后面是arcgis操作省略
public string GetCallbackResult()
{
return m_ADFCallbackFunctionString;
}
总结这个方式是 pageload 下定义 m_ADFCallbackFunctionString = Page.ClientScript.GetCallbackEventReference(this, "message",
"processCallbackResult", "context", "postBackError", true);
之后2个void public void RaiseCallbackEvent(string eventargs)
public string GetCallbackResult() 经过测试是可用的
第二种方式 环境任然是vs2008 asp.net c#
pageload 下定义
a1 = Page.ClientScript.GetCallbackEventReference(this,
"message", "processCallbackResult", "context", "postBackError", true);
a2 = Page.ClientScript.GetCallbackEventReference(this,
"message", "processCallbackResult", "context", "postBackError", true);
a3 = Page.ClientScript.GetCallbackEventReference(this,
"message", "processCallbackResult", "context", "postBackError", true);
private string callbackArg
string ICallbackEventHandler.GetCallbackResult()
{
// 判断是否有相应的缓存信息
string cachedResponse = Cache[callbackArg] as string;
if (cachedResponse != null)
{
return cachedResponse;
}
// 将传入参数依据&分割符分到querystring变量中
Array keyValuePairs = callbackArg.Split("&".ToCharArray());
NameValueCollection queryString = new NameValueCollection();
string[] keyValue;
string response = "";
if (keyValuePairs.Length > 0)
{
for (int i = 0; i < keyValuePairs.Length; i++)
{
keyValue = keyValuePairs.GetValue(i).ToString().Split("=".ToCharArray());
queryString.Add(keyValue[0], keyValue[1]);