Question : Using web service in javascript for asp.net ajax-enabled web site

Hi,

I created a web service project. In this I have namespace OrdersService and a method as follows:

=========================================
namespace OrdersService
{
    [ScriptService]
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class Service : System.Web.Services.WebService
    {
        public Service()
        {

            //Uncomment the following line if using designed components
            //InitializeComponent();
        }

        [ScriptMethod]
        [WebMethod]


        public int GetCount(string strCustID)
        {
}
=========================================


In in the same solution, I added a ajax-enabled web site and added the web service path as follows:

=====================
       
       
       
       

       

=====================

now using the javascript I want to consume the web service, so I write:

var intOrderCount;

intOrderCount=0;

intOrderCount=OrdersService.Service.GetOrderCount(selectedValue);

But it gives error:
OrdersService is undefined.

Second question I have is,  some books mentioned that I need to create javascript proxy. So in the browser, I should add /js to the .asmx file. But if I do that I get error:
Request format is unrecognized for URL unexpectedly ending in '/js'.

Any help on the above 2 issues?

Regards,
mi

Answer : Using web service in javascript for asp.net ajax-enabled web site

At the moment, the script is not included with the servicereference.  You need to add the property InlineScript="true" to the ServiceReference.

See http://asp.net/ajax/documentation/live/tutorials/ExposingWebServicesToAJAXTutorial.aspx
Random Solutions  
 
programming4us programming4us