Click here to Skip to main content
15,498,652 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI,
I need to pass the parameter '999999999' to an webservice when i execute iam getting the error System.InvalidOperationException: Missing parameter: callerid.

pls help me out.


JavaScript
function SearchText() {
     $('#<%= txtusername.ClientID%>').autocomplete({
         source: function (request, response) {
             $.ajax({
                 type: "POST",
                 contentType: "application/json; charset=utf-8",
                 url: "../HttpHandler/Autocomplete.asmx/GetCallername",
                 data: "{'callerid':'" +9999999999+ "'}",
                 dataType: "json",
                 success: function (data) {
                     response(data.d);
                     alert('i enter');
                 },
                 error: function (result) {
                     alert("Error");
                 }
             });
         }
     });
 }


webservice :
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using MSDataAccess;
using System.Data;

namespace Sun.HttpHandler
{
    /// <summary>
    /// Summary description for Autocomplete
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class Autocomplete : System.Web.Services.WebService
    {

        [WebMethod]
        public string GetCallername(string callerid)
        {
            ConnectionCls clsConObj = new ConnectionCls();

            DataSet ds = null;
            string strPriorityOfCall = null;
            object[] obj = new object[6];
            obj[0] = 1;
            obj[1] = 1;
            obj[2] = 1;
            obj[3] = 1;
            obj[4] = 1;
            obj[5] = callerid;

            ds = DataAccess.ExecuteDataset(clsConObj.getConnectionString(), "sp_autoload", obj);
            if (ds.Tables[0].Rows[0]["CallerName"].ToString() != System.DBNull.Value.ToString())
            {
                return ds.Tables[0].Rows[0]["CallerName"].ToString();
            }
            else
            {
                return "User Doesnt Exist";
            }
        }
    }
}
Posted
Updated 19-Jul-13 0:16am
v2

1 solution

Take the 99999999 out of the quotes. You essentially are adding the number plus the string. Since it is just a hard coded number do it like this:

JavaScript
data: "{'callerid':'9999999999'}",
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900