ArcIMS Add dynamic data
ArcIMS_AddDynamicData_VBNet\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 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
Imports ESRI.ArcGIS.ADF.IMS.Data
Imports ESRI.ArcGIS.ADF.IMS.Display
Imports ESRI.ArcGIS.ADF.IMS
Imports ESRI.ArcGIS.ADF.IMS.Carto
Imports ESRI.ArcGIS.ADF.IMS.Carto.Layer
Imports ESRI.ArcGIS.ADF.IMS.Display.Renderer
Imports ESRI.ArcGIS.ADF.IMS.Display.Symbol
Imports System.Collections

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim mapFunc As ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality = _
            CType(Map1.GetFunctionality(0), ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality)

        Dim mapView As MapView = mapFunc.MapView
        Dim drainWkspc As New ShapeWorkspace("riversWorkspace", "C:\Inetpub\wwwroot\sample_data\NorthAmerica")
        Dim drainDataset As New FeatureDataset("rivers", drainWkspc)
        Dim drainLayer As New ESRI.ArcGIS.ADF.IMS.Carto.Layer.FeatureLayer("riversDynamic", drainDataset)
        drainLayer.Type = FeatureType.Line

        Dim drainSymbol As New SimpleLineSymbol(System.Drawing.Color.Blue, 2)
        Dim drainRenderer As New SimpleRenderer(drainSymbol)
        drainLayer.Renderer = drainRenderer
        drainLayer.Name = "Major Rivers"

        ' ArcIMS map configuration file (axl) needs 'MAP dynamic="true"' to work
        mapView.Layers.Add(drainLayer)
        Map1.InitializeFunctionalities()
        Map1.Refresh()

        Toc1.Refresh()

        ' Expand all the Toc nodes upon postback
        Dim tvpnc As ESRI.ArcGIS.ADF.Web.UI.WebControls.TreeViewPlusNodeCollection = Toc1.Nodes

        Dim i As Integer
        For i = 0 To tvpnc.Count - 1
            Dim tvpn As ESRI.ArcGIS.ADF.Web.UI.WebControls.TreeViewPlusNode = tvpnc(i)
            tvpn.Expanded = True

            If tvpn.Nodes.Count > 0 Then
                Dim tvn As ESRI.ArcGIS.ADF.Web.UI.WebControls.TreeViewPlusNode
                For Each tvn In tvpn.Nodes
                    tvn.Expanded = True
                Next tvn
            End If
        Next i

    End Sub 'Button1_Click

End Class '_Default