PUT function demonstration and apiput function demonstration in Web APIs

Source: Internet
Author: User

PUT function demonstration and apiput function demonstration in Web APIs

Insus. NET has been learning and practicing Web APIs over the past few days. How to obtain, submit, or save data. You can review the Post model to Web Api to create or save Data http://www.cnblogs.com/insus/p/4343833.html and add JSON Data to an existing JSON file http://www.cnblogs.com/insus/p/4344547.html, this saves serialized json data to a file.

Now, you can obtain and submit and save the data. Of course, you can update the data. In this article, we will learn how to operate Web APIs to update data, especially to edit and update data in files.

To update data, you must first display the data on the webpage, edit the data, and then update the data. To obtain the Web API data and display it on the webpage, we have learned how to review it here:
ASP. net mvc Web Api practice http://www.cnblogs.com/insus/p/4334316.html
Html Web pages use jQuery to pass Parameters and get Web API data http://www.cnblogs.com/insus/p/4337409.html
Http://www.cnblogs.com/insus/p/4341026.html for transferring multiple parameters and getting Web API data
Post model to Web Api http://www.cnblogs.com/insus/p/4343538.html


Go to the Api controller and add a PUT method. logic processing is described. For more information, see.


Determine whether List <Order> has an existing record:

Var oo = orders. Where (d => d. OrderNumber = order. OrderNumber). FirstOrDefault (); if (oo! = Null ){//...}View Code


Now we create an html webpage to display data and update data. In the dynamically generated data table, we add more columns to dynamically generate an update button after each row. This allows you to update data.

 


OK. Now we can write the jQuery program. First, we can display the data. Before processing this part, because the previous series of retrieved data all come from Entity and are now from files, you need to make some modifications to Get:


The following figure shows the data obtained from the Web Api and dynamically displayed on the logo of span or text:


During the design, you should know which data is editable, and those are read-only data and use different html tags for processing:
If there is no problem at this time, the data should be properly displayed:

Next we can write the Update button event. here we need to note that this button is generated dynamically. When we handle its Click event, we must use the jQuery delegate, for more information about jQuery event processing, see jQuery dynamic production of the ammonium button how to achieve event processing http://www.cnblogs.com/insus/p/4315984.html



Real-time Demonstration:

 

Related Article

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.