1)aspx页面关键句
; 2)初始化:很可能需要在Page_Load中使用 this.ClientScript.GetCallbackEventReference(this, "arg", "context", null);//初始化CallBack 初始化的目的在于使ICallbackEventHandler接口中的方法可以正确的被调用。 也可以使用 Page.ClientScript.GetCallbackEventReference(Page, "argument", "processCallbackResult", "context", true); processCallbackResult是arcgis server环境中自带的一个javascript函数(具体位置:C:\Inetpub\wwwroot\aspnet_client\ESRI\WebADF\JavaScript\display_dotnetadf.js(181):function processCallbackResult(response, context) )
3)消息提示框的内容的实现:
可以通过页面对ICallbackEventHandler接口的继承
private string _callbackArg;
string ICallbackEventHandler.GetCallbackResult()
{ return RaiseCallbackEvent(_callbackArg); }
void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
{ _callbackArg = eventArgument; }
//获取传回页面的字符串
public virtual string RaiseCallbackEvent(string responseString)
{
UserInfo ui = (UserInfo)Session["SessionUserInfo"];
if (ui == null || ui.userID == 0) return ""; // break out the responseString into a querystring Array keyValuePairs = responseString.Split("&".ToCharArray()); NameValueCollection m_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()); m_queryString.Add(keyValue[0], keyValue[1]); } } else { keyValue = responseString.Split("=".ToCharArray()); if (keyValue.Length > 0) m_queryString.Add(keyValue[0], keyValue[1]); } // isolate control type and mode string controlType = m_queryString["ControlType"]; string eventArg = m_queryString["EventArg"]; if (controlType == null) controlType = "IsNull"; string sql = string.Empty; DataTable dt = null; int chkNum = 0, chkNewNum = 0, chkMsgNum = 0, ShareNum = 0, ShareNewNum = 0; int newCount = 0, chkPassNum = 0, chkRejectNum = 0; switch (controlType) { case "QueryMsg": break; case "Ctluserzone1_DrpCountry": break; case "Ctluserzone1_drpProvince": break; case "Ctluserzone1_drpCity": break; default: break; } return response; }
4)把设置好的控件转化为html字符串
private string GetHtmlContent(Control control)
{
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter writer = new HtmlTextWriter(sw);
control.RenderControl(writer);
string htmlContent = sw.ToString(); sw.Close();
return htmlContent;
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/neverain/archive/2009/11/06/4776349.aspx