Hi,
I have a simple form with some text boxes and a couple of buttons. I select a feature and open the form using build in MapGuide Studio functionality. The Page_Load event works and populates the txtFlushedBy textbox with the hydrant number. Then when I click on the cancel button which is supposed to do something fairly innert like set the same textbox to "Hello" I get the "An unclassified exception occurred" error and it sites the "Dim userInfo As MgUserInformation = New MgUserInformation(sessionId)" in the Page_Load event as the source of the error. Anyone have any ideas what the problem is?
Thanks
Code below:
Imports OSGeo.MapGuide
Imports System.Xml
Imports System.Data
Imports System.Data.SqlClient
Partial Class App_Forms_HydrantFlushHistForm
Inherits System.Web.UI.Page
'_________________________________________________________________________________________________
Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
txtFlushedBy.Text = "Hello"
End Sub
'_________________________________________________________________________________________________
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' InvokeURL sends the data as a POST with the following form fields
Dim sessionId As String = Request.Form("SESSION")
Dim mapName As String = Request.Form("MAPNAME")
Dim selectionXml As String = HttpUtility.UrlDecode(Request.Form("Key"))
Dim sHydrantNo As String
' Initialize MapGuide
MapGuideApi.MgInitializeWebTier(Request.MapPath("/mapguide") + "webconfig.ini")
' Open site connection
Dim userInfo As MgUserInformation = New MgUserInformation(sessionId)
Dim siteConnection As New MgSiteConnection
siteConnection.Open(userInfo)
' Get the current map
Dim resourceService As MgResourceService = siteConnection.CreateService(MgServiceType.ResourceService)
Dim map As New MgMap(siteConnection)
map.Open(resourceService, mapName)
' Get the current selection
Dim selection As New MgSelection(map, selectionXml)
For Each layer As MgLayer In selection.GetLayers
' Get number of features for this layer (if you need it)
Dim count As Integer = selection.GetSelectedFeaturesCount(layer, layer.FeatureClassName)
' Read the feature data
Dim featureReader As MgFeatureReader = selection.GetSelectedFeatures(layer, layer.FeatureClassName, False)
While featureReader.ReadNext()
sHydrantNo = featureReader.GetString("HydrantNo")
txtFlushedBy.Text = sHydrantNo
'txtFlushedBy.Text = "Cancel"
'txtFlushedBy.text = sHydrantNo
End While
featureReader.Close()
featureReader.Dispose()
Next
End Sub
End Class