从vb.net方asp.net JSON字符串 [英] json string from vb.net side to asp.net

查看:175
本文介绍了从vb.net方asp.net JSON字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将如何得到我的JSON字符串到我的asp.net我感到困惑的使用Web方法或数组或函数的所有我看到的例子是在C#。我想要的是采取JSON字符串解析它。

How would I get my JSON string to my asp.net using jquery I am confused about using web methods or arrays or functions all the examples i have seen are in C#. All i want is to take the json string parse it.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
    cmd.Connection = conn
    conn.Open()
    Dim ds As New DataSet
    cmd.CommandText = "MY SELECT STATEMENT IS IN HERE(DIDNT WANT TO POST ONLINE)"
    da.Fill(ds)
    da.FillSchema(ds, SchemaType.Mapped)
    Dim myObject = ds.GetXml
    Dim jsonString = New JavaScriptSerializer().Serialize(myObject)
   conn.Close()
End Sub

我想借此无论是jsonstring或为MyObject到服务器端。 jsonstring是JSON和myObject的是XML。这样我可以创建一个表,客户端将包括数学函数。我非常在这个新的,所以我需要一个明确的解释,甚至一个例子。我看了一下pagemethods,我已经使用上调用服务器端功能例如

或者你可以告诉我一个简单的方法从SQL去阿贾​​克斯。什么是将大型数据集一个asp.net页面上,而无需使用分页的最佳方法。

Or can you tell me a simple way to go from sql to ajax. What is the best method for placing large datasets on a asp.net page without using paging.

我基本上重写,他们现在使用使用Ajax一个asp页面,因为它加载缓慢,目前的ASP code下面有一个我试图达到的。例如和

I am basically rewriting an asp page that they use now to use ajax, because it loads to slow, heres an example of the current asp code and what I am trying to achieve.

                response.write("<tr><td>")

            %><font face="Arial,Helvetica,sans-serif" size="-2"><%
            response.write(rscontest.fields.item("book7"))
            response.write("</td><td>")

            %><font face="Arial,Helvetica,sans-serif" size="-2"><%
            response.write(rscontest.fields.item("dep7"))
            response.write("</td><td>")

            %><font face="Arial,Helvetica,sans-serif" size="-2"><%
            response.write(rscontest.fields.item("lead"))
            response.write("</td><td>")

            %><font face="Arial,Helvetica,sans-serif" size="-2"><%
            response.write(rscontest.fields.item("hear"))
            response.write("</td><td>")

            %><font face="Arial,Helvetica,sans-serif" size="-2"><%
            response.write(rscontest.fields.item("cname"))
            response.write("</td><td>")

%><font face="Arial,Helvetica,sans-serif" size="-2"><%


response.write(rscontest.fields.item("theme") & " - " & rscontest.fields.item("tour"))
            response.write("</td><td align='right'>")

            %><font face="Arial,Helvetica,sans-serif" size="-2"><%
            response.write(rscontest.fields.item("userid"))
            response.write("</td><td align='right'>")

            %><font face="Arial,Helvetica,sans-serif" size="-2"><%
            response.write(rscontest.fields.item("pax_count"))
            pax = pax + rscontest.fields.item("pax_count")
            response.write("</td><td align='right'>")

            %><font face="Arial,Helvetica,sans-serif" size="-2"><%
            IF rscontest.fields.item("status") = "XL" then
                response.write(formatnumber(rscontest.fields.item("CXVALUE"),2))
                sales = sales - formatnumber(rscontest.fields.item("CXVALUE"),2)
            ELSE
                response.write(formatnumber(rscontest.fields.item("AMOUNT"),2))
                sales = sales + formatnumber(rscontest.fields.item("AMOUNT"),2)
            END IF

        response.write("<tr><td rowspan=1>")    
        %><font face="Arial,Helvetica,sans-serif" size="-2"></style><%
            response.write(rscontest.fields.item("description"))




            rscontest.movenext

        wend

什么是写作是一个SQL语句,它使用一个运行总计。

anything it is writing is from an sql statement, and it uses a running total.

推荐答案

首先,阅读的这个SO线程,如果​​它不能帮助 - 读

First, read this SO thread, if it doesn't help - read on.

我不知道为什么你想传递后,你周围的web服务获得和JSON,但下面的步骤应该让你有:

I'm not sure why you want to pass the json around after you get if from the webservice, but the following steps should get you there:

  1. 创建一个web服务(首先从模板默认HelloWorld服务)
  2. 调用来自javasscript的web服务( jQuery的$。阿贾克斯()做到了这一点)
  3. 在指定的XML(JSON)您从Web服务到一个隐藏字段(用asp:HiddenField,以确保它在服务器上可用)
  4. 在code后面 - 得到隐藏字段的值,做什么,你必须用它做
  1. Create a webservice (start with a default HelloWorld service from the template)
  2. Call the webservice from javasscript (jQuery's $.ajax() does just that)
  3. Assign the xml (json) that you get from the webservice to a hidden field (use asp:HiddenField to make sure it's available on the server)
  4. In your code behind - get the value of the hidden field, and do what you have to do with it.

您真的应该改一下你的问题,并告诉我们的最终目标是什么。当你说我要建一个表,这并不意味着什么。

You should really rephrase your question, and tell us what the ultimate goal is. When you say "I want to build a table", that doesn't mean anything.

这篇关于从vb.net方asp.net JSON字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆