CYQ. Data framework application example JSON Communication

Source: Internet
Author: User

Preface:

I haven't written any tutorials for a long time. The version upgrade is very fast. Because all versions are backward compatible, the original tutorials also apply,

If you have time, please update it manually.

There are some new functions available for the time being, all of which are scattered in the articles of the released version. Therefore, everyone should leave their posts of different versions empty.

Today, we have carefully written an example to demonstrate a json application in the cyq. Data framework that has not been taken seriously by everyone.

 

The following is an example:

 

I. Function list

 

1: publish a WebService. Two methods are provided:

A: Query table data: public string GetUsersInfo ()

B: data update [with insert]: public bool UpdateUserInfo (string json)

 

2: Local Aspx page:

A: directly call GetUsersInfo of WebService and bind it to the list control.

B: Use Jquery to read WebService and output data cyclically.

C: Use Jquery to call UpdateUserInfo and submit data.

 

3: solution:

 

For this example, the QBlog database of the autumn garden is also used.

 

Ii. Project implementation steps

 

1: Download V4.3 from the download center and configure the database link. skip this step.

2: Reference CYQ. Data framework -- skipped

 

3: Add a WebService and add the following two methods:

 

4: Add a WebService reference

 

5. Interface call:

A: html

<Asp: GridView ID = "gvUsers" runat = "server"> </asp: GridView>

B: Default. aspx

Protected void Page_Load (object sender, EventArgs e)
{
Localhost. Service s = new localhost. Service ();
MDataTable. LoadFromJson (s. GetUsersInfo (). Bind (gvUsers );;
}

 

6: F5 result 1:

 

7. Interaction with Jquery call 1: query data:

A: html

<Div id = "jsonBody" title = "display a Div"> </div>

At the same time, onload = "loadData ()" is added to the body. The script that triggers the event is as follows:

B: Call result:

 

8: interaction with Jquery call 2: submit data:

A: html: one input box and one submit button

<Input id = "txtJson" type = "text" value = "" style = "width: 300px"/>
<Input type = "button" value = "Submit Update" onclick = "updateData ()"/>

B: Call jquery to submit data:

C: Enter the data on the page and prepare to submit the data:

D: the submitted data results have been updated as follows:

 

Iii. Summary and examples:

 

By nature, you can understand the application of CYQ. Data framework in network communication JSON.

 

From the sample code in this section, the application is quite simple and convenient:

You can easily convert a table to JSON, and easily restore it from JSON to a table. A table can also be converted to a List <T> entity.

 

Even the communication applications based on WCF and Silverlight are very convenient.

 

Finally: Sample packaging: http://www.cyqdata.com/download/article-detail-28683

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.