VegWebAppCSharp\Default.aspx.cs
// Copyright 2010 ESRI // // All rights reserved under the copyright laws of the United States // and applicable international laws, treaties, and conventions. // // You may freely redistribute and use this sample code, with or // without modification, provided you include the original copyright // notice and use restrictions. // // See the use restrictions. // 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; public partial class _Default : System.Web.UI.Page, ICallbackEventHandler { public string sCallBackFunctionInvocation; private string returnstring = ""; public void RaiseCallbackEvent(string eventArgs) { if (eventArgs.Contains("tbx")) { ChangeTextBoxServer(eventArgs); } else if (eventArgs.Contains("cbx")) { ChangeCheckBoxServer(eventArgs); } else if (eventArgs.Contains("map1")) { ChangeMapServer(); } } public string GetCallbackResult() { return returnstring; } public void ChangeTextBoxServer(string ea) { char[] parser_char = { ',' }; string[] messages = ea.Split(parser_char); string value = messages[1]; Session["TextBox1Value"] = value; } public void ChangeCheckBoxServer(string ea) { char[] parser_char = { ',' }; string[] messages = ea.Split(parser_char); string value = messages[1]; Session["CheckBox1Value"] = value; } public void ChangeMapServer() { DataSet ds = (DataSet) Session["VegDataset"]; if (ds != null) { GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); using (System.IO.StringWriter sw = new System.IO.StringWriter()) { HtmlTextWriter htw = new HtmlTextWriter(sw); GridView1.RenderControl(htw); htw.Flush(); returnstring = sw.ToString(); } } } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Session["TextBox1Value"] = "10000"; Session["CheckBox1Value"] = "false"; Session["VegDataset"] = null; } CheckBox1.Attributes.Add("onclick", "ChangeContext('CheckBox1')"); TextBox1.Attributes.Add("onblur", "ChangeContext('TextBox1')"); Map1.Attributes.Add("onmouseup", "ChangeContext('Map1')"); sCallBackFunctionInvocation = Page.ClientScript.GetCallbackEventReference(this, "message", "HandleResponse", "context", "postBackError", true); } }