+ Reply to Thread
Results 1 to 2 of 2

Thread: Flex to ASP.NET - best way to attach a FeatureSet to the request for an ASP page

  1. #1
    Bill Wiesepape
    Join Date
    Apr 2010
    Posts
    10
    Points
    1
    Answers Provided
    0


    1

    Default Flex to ASP.NET - best way to attach a FeatureSet to the request for an ASP page

    If I have a QueryTask in Flex that is generating a FeatureSet, what is the best way to pass the features in the FeatureSet to an ASP.NET page? QueryString? Should I use JSON to incode the results? If necessary I can just pass an Array with two strings and two real numbers per record, I do not need the graphics object.

  2. #2
    Bill Wiesepape
    Join Date
    Apr 2010
    Posts
    10
    Points
    1
    Answers Provided
    0


    0

    Default Re: Flex to ASP.NET - best way to attach a FeatureSet to the request for an ASP page

    After some effort I came up with the below. BTW: Thanks Rex Hanson for realizing that some of us might need to do this outside of ESRI: http://rexdotnet.blogspot.com/2009/1...pi-in-net.html Next Dev Summit I owe you a beer!

    Flex:

    Code:
    queryTask.execute(query, new AsyncResponder(onResult, onFault));
    				function onResult(featureSet:FeatureSet, token:Object = null):void
    				{
    					jsonResults = featureSet.toJSON();
                                                                                   var request:URLRequest = new URLRequest("http://bwiespape/GeotechExample2ASP/simple.aspx");
    				 
    				                request.data = { j: jsonResults};
    				
                                                                                   // if you don't need a file back you could just as easily use HTTPService here
    				                var fileRef:FileReference = new FileReference();
    				                fileRef.download(request,"report.pdf");
    				}
    ASP.net

    Code:
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim serializer As JavaScriptSerializer
    
            Dim nvc As NameValueCollection = Request.Form
            Dim responseString As String = nvc("j")
    
            serializer = New JavaScriptSerializer()
    
            If responseString IsNot Nothing Then
    
                Dim results As IDictionary(Of String, Object) = TryCast(serializer.DeserializeObject(responseString), IDictionary(Of String, Object))
    
                If results IsNot Nothing AndAlso results.ContainsKey("features") Then
                    Dim features As IEnumerable(Of Object) = TryCast(results("features"), IEnumerable(Of Object))
    
                    For Each feature As IDictionary(Of String, Object) In features
                        Dim attributes As IDictionary(Of String, Object) = TryCast(feature("attributes"), IDictionary(Of String, Object))
    
                        Dim project_nu As String = TryCast(attributes("Project_Nu"), String)
                        Dim pointid As String = TryCast(attributes("PointID"), String)
                        Dim east As Double = Decimal.ToDouble(CDec(attributes("East")))
                        Dim north As Double = Decimal.ToDouble(CDec(attributes("North")))
    
                        'Do Something with your results, array, whatever
                        
                    Next
                End If
            End If
        End Sub
    Last edited by billwie; 05-16-2012 at 02:05 PM.

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts