ASP. net mvc submits a complex object to the WCF Service

Source: Internet
Author: User

In the previous article jQuery. Ajax () method of executing the WCF Service http://www.cnblogs.com/insus/p/3727875.html, We have exercises in the asp.net mvc application, POST data to the wcf service and execute the method.

This exercise submits more complex objects to the wcf service Execution method. In the previous article, only two parameters are passed. If we usually develop and need to pass too many parameters, we need to write many parameters. Therefore, this article creates multiple parameters as an object. Then, you only need to pass this object to the wcf service.

Next, create an object that supports the wcf service under the directory structure Models of asp.net mvc:



Create two methods in the wcf service Interface. One is to pass in the primary key value and obtain the IEnumerable <Insus. NET. Models. FruitKind> GetByPrimaryKey (byte fruitKind_nbr) of a single record ). The other is to Update the data void Update (Insus. NET. Models. Kind k ):

 

The following two methods are implemented:

 

Next, we will refer to ASP. net mvc call methods for WCF Service in this example http://www.cnblogs.com/insus/p/3720547.html,:

 

The running result is as follows:

 
Add a view operation (Action) to the Controller ):


In this way, you can click the "details" link to jump to this view. This record is displayed and can be modified and updated by the user:

 
Mark 1 and Mark 2 are html markup and reference Qjery and custom js libraries.

Mark 3: load data:

 

Mark 4: each field is generated dynamically. :

 

Mark 5 to get the parameters in the address bar:

Mark 6 to update the button:

 

Real-time operation 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.