www.pudn.com > ExportLegend.rar > Default.aspx.cs, change:2008-10-04,size:2638b


using System; 
using System.Data; 
using System.Configuration; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Web.UI.HtmlControls; 
using System.Collections.Specialized; 
 
public partial class _Default : System.Web.UI.Page, ICallbackEventHandler  
{ 
    public string getLegendCallBack; // 客户端脚本段 
    private string callbackArg; // 返回给客户端的内容 
 
    protected void Page_Load(object sender, EventArgs e) 
    { 
        // 利用GetCallbackEventReference方法生成客户端脚本 
        getLegendCallBack = Page.ClientScript.GetCallbackEventReference(this, 
            "message", "processCallbackResult", "context", "postBackError", true); 
    } 
 
    #region ICallbackEventHandler Members 
 
    void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument) 
    { 
        callbackArg = eventArgument; 
    } 
 
    string ICallbackEventHandler.GetCallbackResult() 
    { 
        // 将传入参数依据&分割符分到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]); 
            } 
        } 
        else 
        { 
            keyValue = callbackArg.Split("=".ToCharArray()); 
            if (keyValue.Length > 0) 
                queryString.Add(keyValue[0], keyValue[1]); 
        } 
 
 
        // 针对参数中指定的ActiveType不同执行不同操作 
        string controlType = queryString["ActiveType"]; 
        switch (controlType) 
        { 
            case "GetLegend": 
                { 
                     
                    // 根目录虚拟路径 
                    string virtualPath = Page.Request.ApplicationPath; 
                    // 根目录绝对路径 
                    //string pathRooted = HostingEnvironment.MapPath(virtualPath); 
                    string pathRooted = HttpContext.Current.Server.MapPath(virtualPath); 
                    string savePath = pathRooted + "\\Output\\Legend.bmp"; 
                    response = GisFunctionality.GetLegend(Map1, savePath); 
                    break; 
                } 
            default: 
                break; 
        } 
                 
        return response; 
    } 
 
    #endregion 
}