Click here to Skip to main content
15,887,083 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: textbox wrap to several lines Pin
classy_dog9-Aug-12 12:07
classy_dog9-Aug-12 12:07 
AnswerRe: textbox wrap to several lines Pin
R. Giskard Reventlov9-Aug-12 12:40
R. Giskard Reventlov9-Aug-12 12:40 
QuestionA liitle help on submitting a json array, no-primitive to a web service Pin
jkirkerx9-Aug-12 8:49
professionaljkirkerx9-Aug-12 8:49 
AnswerI think I did it, got my json reponse back with no error during testing. Pin
jkirkerx9-Aug-12 17:03
professionaljkirkerx9-Aug-12 17:03 
QuestionRe: A liitle help on submitting a json array, no-primitive to a web service Pin
CodeHawkz9-Aug-12 20:54
CodeHawkz9-Aug-12 20:54 
AnswerRe: A liitle help on submitting a json array, no-primitive to a web service Pin
jkirkerx10-Aug-12 6:26
professionaljkirkerx10-Aug-12 6:26 
AnswerRe: A liitle help on submitting a json array, no-primitive to a web service Pin
CodeHawkz12-Aug-12 8:48
CodeHawkz12-Aug-12 8:48 
GeneralRe: A liitle help on submitting a json array, no-primitive to a web service Pin
jkirkerx12-Aug-12 10:25
professionaljkirkerx12-Aug-12 10:25 
Oh, that's pretty slick.

I built my json the old fashioned way using string builder.

I just caught the net4.0 comment, using 2.0 on this project.

I was just fine tuning my function to correct the first record error being sort of blank.

<WebMethod()> _
   Public Function create_DynamicCart_Template(
       ByVal template_Name As String,
       ByVal template_Array() As templateElements) As String

       Dim dwExitCode As Integer = 2 'An unknown error has occured
       Dim json_response As StringBuilder = New StringBuilder

       Try
           Dim bTemplates As Boolean = DoesFoldersExist("~/App_Data/Products/dynamicItems/templates")
           Dim bDisplay As Boolean = DoesFoldersExist("~/App_Data/Products/pageDisplay")

           'Create the First Record
           Dim new_Template As dynamicItem3.template = New dynamicItem3.template
           Dim new_Element1 As dynamicItem3.templateElement_1 = New dynamicItem3.templateElement_1

           new_Element1.Name = template_Array(0).Name
           new_Element1.suffix = template_Array(0).Code

           If (template_Array(0).Type.ToUpper = "SIMPLE") Then
               new_Element1.elementType = dynamicItem3.templateElement_1ElementType.Simple
           Else
               new_Element1.elementType = dynamicItem3.templateElement_1ElementType.Complex
           End If

           Dim new_Element1_Record() As dynamicItem3.templateElement_1 = {new_Element1}
           Dim new_Element1_Record_Count As Integer = 0

           'Now Build the rest of the records
           For i As Integer = 1 To template_Array.Length - 1
               'Build the XML Array from the JSON Array
               Array.Resize(new_Element1_Record, new_Element1_Record.Length + 1)
               new_Element1_Record(new_Element1_Record.Length - 1) = New dynamicItem3.templateElement_1
               new_Element1_Record(new_Element1_Record.Length - 1).Name = template_Array(i).Name
               new_Element1_Record(new_Element1_Record.Length - 1).suffix = template_Array(i).Code

               If (template_Array(i).Type.ToUpper = "SIMPLE") Then
                   new_Element1_Record(new_Element1_Record.Length - 1).elementType = dynamicItem3.templateElement_1ElementType.Simple
               Else
                   new_Element1_Record(new_Element1_Record.Length - 1).elementType = dynamicItem3.templateElement_1ElementType.Complex
               End If

               new_Element1_Record_Count += 1
           Next i

           'Package the Array into Pure Sweet XML, and write it to the Disk Drive
           Dim DataLocation As String = Nothing
           DataLocation = HttpContext.Current.Server.MapPath("~/App_Data/Products/dynamicItems/templates/" & template_Name & ".xml")

           Dim XmlResponse As New dynamicItem3.template
           XmlResponse.Version = "1.0"
           XmlResponse.CreationDate = DateTime.Now.ToString("yyyy-MM-dd")
           XmlResponse.templateName = template_Name
           XmlResponse.element_1 = new_Element1_Record

           'Now Lets Write out the file as a MemoryStream
           Dim serializer As XmlSerializer
           serializer = New XmlSerializer(GetType(dynamicItem3.template))

           'Now we have to write out a file for certification
           Dim response_serializer As XmlSerializer = Nothing
           response_serializer = New XmlSerializer(GetType(dynamicItem3.template))

           Dim Writer As StreamWriter = Nothing
           Writer = New StreamWriter(DataLocation)
           response_serializer.Serialize(Writer, XmlResponse)

           Writer.Close()
           Writer = Nothing

           response_serializer = Nothing
           serializer = Nothing
           XmlResponse = Nothing

           dwExitCode = 0

       Catch ex As Exception
           'An error occured building the XML - Send 1
           dwExitCode = 1

       End Try

       With json_response
           .Append("{")
           .Append(" ""template_ExitCode"" : " & dwExitCode.ToString & " ")
           .Append("}")
       End With

       Dim js_response As System.Web.Script.Serialization.JavaScriptSerializer = New System.Web.Script.Serialization.JavaScriptSerializer
       js_response.Serialize(json_response.ToString)
       js_response = Nothing

       Return json_response.ToString

   End Function

GeneralRe: A liitle help on submitting a json array, no-primitive to a web service Pin
CodeHawkz12-Aug-12 17:23
CodeHawkz12-Aug-12 17:23 
GeneralRe: A liitle help on submitting a json array, no-primitive to a web service Pin
jkirkerx13-Aug-12 7:17
professionaljkirkerx13-Aug-12 7:17 
GeneralRe: A liitle help on submitting a json array, no-primitive to a web service Pin
CodeHawkz29-Aug-12 19:17
CodeHawkz29-Aug-12 19:17 
GeneralRe: A liitle help on submitting a json array, no-primitive to a web service Pin
jkirkerx30-Aug-12 6:04
professionaljkirkerx30-Aug-12 6:04 
GeneralRe: A liitle help on submitting a json array, no-primitive to a web service Pin
CodeHawkz30-Aug-12 20:34
CodeHawkz30-Aug-12 20:34 
GeneralRe: A liitle help on submitting a json array, no-primitive to a web service Pin
jkirkerx31-Aug-12 6:25
professionaljkirkerx31-Aug-12 6:25 
QuestionPage.Response.Redirect not working Pin
dcof9-Aug-12 5:21
dcof9-Aug-12 5:21 
AnswerRe: Page.Response.Redirect not working Pin
jkirkerx9-Aug-12 6:50
professionaljkirkerx9-Aug-12 6:50 
AnswerRe: Page.Response.Redirect not working Pin
AspDotNetDev9-Aug-12 6:51
protectorAspDotNetDev9-Aug-12 6:51 
AnswerMessage Closed Pin
9-Aug-12 8:14
professionaljkirkerx9-Aug-12 8:14 
GeneralRe: Page.Response.Redirect not working Pin
dcof9-Aug-12 12:11
dcof9-Aug-12 12:11 
GeneralRe: Page.Response.Redirect not working Pin
jkirkerx9-Aug-12 17:09
professionaljkirkerx9-Aug-12 17:09 
GeneralRe: Page.Response.Redirect not working Pin
dcof9-Aug-12 18:40
dcof9-Aug-12 18:40 
AnswerRe: Page.Response.Redirect not working Pin
dipurajp10-Aug-12 2:42
dipurajp10-Aug-12 2:42 
GeneralRecursion from asp classic to asp net Pin
EnricoRS19-Aug-12 4:45
EnricoRS19-Aug-12 4:45 
AnswerRe: Recursion from asp classic to asp net Pin
Wes Aday9-Aug-12 5:54
professionalWes Aday9-Aug-12 5:54 
GeneralRe: Recursion from asp classic to asp net Pin
EnricoRS19-Aug-12 9:00
EnricoRS19-Aug-12 9:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.