Free Jobs

Dot Net Forums: ASPNET (77) C#.NET (39) VB.NET (8) AJAX (21) Silver Light (1) WCF (10) WPF (1) WWF (1) .NET 3.5 (3) SQL SERVER (38) Other (3)

Topic: How to call a WCF Service using AJAX ScriptManager from ASP.NET

To get the Posted Questions details daily in your mail Click Here

Share this Post on Facebook/Twitter/Orkut Bookmark and Share

User: dhiraj5079 Post Date: 13 May 2011 08:50

How to call a WCF Service using AJAX ScriptManager from ASP.NET

Main Content:
We can call WCF Webservice using AJAX script manager as below

Add the below code in the .aspx page.

<div> <input id="TextCode1" name="output" value="Code1" type="text" /> <input id="TextCode2" name="output" value="Code2" type="text" /> </div> <div> <script language="javascript" type="text/javascript"> var Code1 = document.getElementById('TextCode1').value; var Code2 = document.getElementById('TextCode2').value; function GetValueFromServer() { WCFAjaxTestService.HelloWorld(Code1, Code2, onSuccess, onFailure); } function onSuccess(result) { document.getElementById('txtValueContainer').value = result; } function onFailure(result) { window.alert(result); } </script> <asp:ScriptManager ID="ScriptManager2" runat="server"> <Services> <asp:ServiceReference Path="~/WCFAjaxTestService.svc" /> </Services> </asp:ScriptManager> <input id="btnServiceCaller" type="button" value="Get Value" onclick="GetValueFromServer()"; /> <input id="txtValueContainer" type="text" value="" /> </div>

Thus when you will btnServiceCaller the result will be displayed in the text box.

About Writer:
Hi,I am IT Professional From Mumbai

Writer's Link: http://

Writer's Email:

Post Comment

Similar Articles Top ArticlesLatest Articles Other Articles by this Author Copyright © 2009-2011 | All Rights Reserved
All content of this website is protected by copyright laws and should not be reproduced in any form or by any means without written permission
(Best viewed in IE 8.0+ or Firefox 3.0+ at resolution of 1024 * 768 or higher)