Sunday, September 5, 2010

To call a Javascript from a class which is not derived from Web Page in ESRI ArcGIS Server ADF

Problem :

To call a Javascript function from a C Sharp class in ArcGIS Server ADF Application. 

Possible Solutions :

Use a callbackresult and add it to the Map Control as shown below.


public class DownloadMap : IMapServerToolAction
{
#region IMapServerToolAction Members

void IMapServerToolAction.ServerAction(ESRI.ArcGIS.ADF.Web.UI.WebControls.ToolEventArgs args)
{
Map map = (Map)args.Control;
MapCircleEventArgs theMapCircleEventArgs = (MapCircleEventArgs)args;
map.Page.Session["CircleCenterX"] = theMapCircleEventArgs.MapCenter.X.ToString();
map.Page.Session["CircleCenterY"] = theMapCircleEventArgs.MapCenter.Y.ToString();
map.Page.Session["CircleRadius"] = theMapCircleEventArgs.MapRadius.ToString();
StringBuilder sb = new StringBuilder();
sb.Append("function owin() { window.open('DownloadPage.aspx'); } owin() ;");
ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult theCallbackResult = ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult.CreateJavaScript(sb.ToString());
map.CallbackResults.Add(theCallbackResult);
}
#endregion
}

No comments:

Post a Comment

All Blogs so far ...