Click here to Skip to main content
13,597,584 members
Click here to Skip to main content
Add your own
alternative version


10 bookmarked
Posted 20 Aug 2010
Licenced CPOL

Webservice Using Javascript.

, 27 Aug 2010
Rate this:
Please Sign up or sign in to vote.


This Little Code just gives you hands on trick to access Webservice using Javascript.


I had knew that webservice can be accessed by Javascript but haven't thought that much eeasy way. Have a Look at it.

Using the Code

Lets Start Step By Step.

Step 1

Add Script Manager Instance to your ASPX Page, Here i have specified path of my webservice (QuoteService.asmx).

<asp:ScriptManager ID="_ScriptManager" runat="server">
                <asp:ServiceReference Path="~/QuoteService.asmx" />

Step 2

Add Below Mentioned Attribute to your code behind of Webservice (in my case QuoteService.cs)

[WebService(Namespace = "")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

And Write Some method to your Webservice Code Behind Class . ( In my case QuoteService.cs)

public string GetQuote(int intVar)
return (intVar + 6).ToString();

Step 3

Call a Function from Javascript and define the Return value handler of function.

function LookUp() {
            QuoteService.GetQuote(2, OnLookupComplete)

Define result Handler Function as Depicted in above code

function OnLookupComplete(result) {

So Guyz We are done with our Tricks.

Points of Interest

I just was thinking it will be to time taking concept to calling webservice from javascript but as i searched through net . i found very simple solution, so i thought may it will be useful to you also in some part of code.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Hiren solanki
Software Developer
India India
He is a Smart IT devloper with Few years of Expeariance But having Great command on,C#,SQL Query,SSRS,Crystal Reports

Apart from that He Loves multimedia work too, Master of Adobe photoshop, Illustrator, CSS , HTML and all things.

He is Currently working in Microsoft Dynamics CRM and Having Nice Expearince with CRM. CRM Rocks!!!

You may also be interested in...


Comments and Discussions

Generalthanks for your comments. Pin
Hiren Solanki20-Aug-10 16:52
memberHiren Solanki20-Aug-10 16:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01 | 2.8.180621.3 | Last Updated 27 Aug 2010
Article Copyright 2010 by Hiren solanki
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid