Web方法的用途是什么,是ASP .Net应用程序的必要条件 [英] What is the use of web methods and is it necessary for an ASP .Net application

查看:136
本文介绍了Web方法的用途是什么,是ASP .Net应用程序的必要条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在我的项目中,我需要在web方法的帮助下使用JSON和AJAX。我使用ASP控件而不是HTML。我有一个提交按钮点击我的项目。但在这里我使用普通的服务器端控件将数据保存到SQL Server数据库。但由于页面刷新。所以我需要使用客户端代码而不是服务器端代码。请帮助我详细了解所有3件事:web方法,JSON和AJAX以避免页面重新加载。

Hi,
In my project I need to use JSON and AJAX with the help of web method. I am using ASP controls instead of html. I have a submit button click on my project. But here I use normal server side controls to save data to SQL Server database. But due to that the page refreshes. So I need to use client side codes instead of server side code. Please help me the details of usage of all the 3 things: web methods, JSON and AJAX to avoid page reload.

推荐答案

如果你不想完整的页面刷新那么您可以将控件包装在更新面板中。或者,更好的方法是创建基本的html控件,然后进行Web Service或Web Api调用以执行服务器端代码。 service / api可以以JSON的形式返回数据,可以根据您的需要使用。这只是您应该如何进行的概述,有关详细信息,您可以参考以下内容,或者您​​应该谷歌搜索各种问题。



http://www.asp.net/web-api [ ^ ]

http://msdn.microsoft.com/en-us/library/8wbhsy70(v=vs.90).aspx [ ^ ]



:)
If you do not want complete page refreshes then you can wrap your controls in an Update Panel. Alternatively, the better way is to create basic html controls and then make Web Service or Web Api calls to execute server side code. The service/api can return data in the form of JSON which can be used as per your needs. This is just an overview of how you should proceed, for more details you can refer to the following, or you should google for a variety of questons.

http://www.asp.net/web-api[^]
http://msdn.microsoft.com/en-us/library/8wbhsy70(v=vs.90).aspx[^]

:)


这篇关于Web方法的用途是什么,是ASP .Net应用程序的必要条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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