Server spatial query COM utility
VegWebAppVBNet\Default.aspx.vb
' 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.
' 

Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Partial Public Class _Default
  Inherits System.Web.UI.Page
  Implements ICallbackEventHandler
  Public sCallBackFunctionInvocation As String
  Private returnstring As String = ""

  Public Sub RaiseCallbackEvent(ByVal eventArgs As String) Implements ICallbackEventHandler.RaiseCallbackEvent
    If eventArgs.Contains("tbx") Then
       ChangeTextBoxServer(eventArgs)
     ElseIf eventArgs.Contains("cbx") Then
       ChangeCheckBoxServer(eventArgs)
     ElseIf eventArgs.Contains("map1") Then
       ChangeMapServer()
     End If
  End Sub

  Public Function GetCallbackResult() As String Implements ICallbackEventHandler.GetCallbackResult
    Return returnstring
  End Function

  Public Sub ChangeTextBoxServer(ByVal ea As String)
    Dim parser_char() As Char = { ","c }
    Dim messages() As String = ea.Split(parser_char)
    Dim value As String = messages(1)
    Session("TextBox1Value") = value
  End Sub

  Public Sub ChangeCheckBoxServer(ByVal ea As String)
    Dim parser_char() As Char = { ","c }
    Dim messages() As String = ea.Split(parser_char)
    Dim value As String = messages(1)
    Session("CheckBox1Value") = value
  End Sub

  Public Sub ChangeMapServer()
    Dim ds As DataSet = CType(Session("VegDataset"), DataSet)

    If ds IsNot Nothing Then
      GridView1.DataSource = ds.Tables(0)
      GridView1.DataBind()

      Using sw As New System.IO.StringWriter()
        Dim htw As New HtmlTextWriter(sw)
        GridView1.RenderControl(htw)
        htw.Flush()
        returnstring = sw.ToString()
      End Using
    End If
  End Sub

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    If (Not IsPostBack) Then
      Session("TextBox1Value") = "10000"
      Session("CheckBox1Value") = "false"
      Session("VegDataset") = Nothing

    End If
    CheckBox1.Attributes.Add("onclick", "ChangeContext('CheckBox1')")
    TextBox1.Attributes.Add("onblur", "ChangeContext('TextBox1')")
    Map1.Attributes.Add("onmouseup", "ChangeContext('Map1')")
    sCallBackFunctionInvocation = Page.ClientScript.GetCallbackEventReference(Me, "message", "HandleResponse", "context", "postBackError", True)
  End Sub

End Class