Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone
i'm new to web services in asp.net. well basically in my asp.net Solution ,it has 3 basic projects namely (PAL(all the web form interfaces are there) , BAL(refer business logic) and DAL ( refer data access -SQL server part). PAL is linked to BAL and BAL is LINKED to DAL. then i want to add a Ajax auto complete extender to a Textbox in a web form located at PAL .just say testwebform.aspx and i write a webService in a BAL namely webService1 and add a webmethod as follows..


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.Sql;
using AjaxControlToolkit;
using DAL;

namespace BAL
{
    /// <summary>
    /// Summary description for WebService1
    /// </summary>
    [WebService(Namespace = "http://testserver/webservices")]
    [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]
     //[System.Web.Services.WebMethod]
     //[System.Web.Script.Services.ScriptMethod]

    public class WebService1 : System.Web.Services.WebService
    {

        [WebMethod]
        public String[] GetCompanyList(String prefixText, Int32 count)
        {
            String[] strList = null;
            List<string> strCompanyList = new List<string>();

            String Consigneeprefix = prefixText + "%";
            String Sql = "SELECT TOP'"+count+"'[conCode],[conName] FROM [tblConsignee] WHERE [cusCode] ='"+webSupport.ShipperCode().Trim() +"' AND  [conName] LIKE'" + Consigneeprefix +"'";

// webSupport.ShipperCode refer to get the ShipperCode for Sql Query String via.

            DataTable dt = new DataTable();
            dt = SQLTrans.executeQuery(Sql, "tbl");

            if (dt.Rows.Count> 0)
 
            {
                for ( int i = 0 ; i< dt.Rows.Count;i++)
                {
                  // Here is the Douted area in web method.

                  strCompanyList.Add(AjaxControlToolkit.AutoCompleteExtender.
                  CreateAutoCompleteItem(dt.Rows[i][0].ToString(), Convert.ToString(dt.Rows[i][1].ToString())));


                }

                strList = new String[10];
                strList = strCompanyList.ToArray();


            }
            else
            {
                //No records found

            }
            
            return strList;
        }
    }
}




then i called the web service method from PAL's particular webform by using following AJAX auto completeextender as follows. and it says "Server tag is Not well formed". i refer Using AJAX AutoCompleteExtender for autosuggest[^] to get the idea of webServices and AJAX auto Complete extender.But i also dnt know how to Link return SQL query's return two Fields([conCode],[conName]) values. it is conCode to a value flied of the Extender and conNameto Text feild in the Ajax extender.


<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

<asp:TextBox ID="TextBox1" runat="server" Height="19px" Width="256px"></asp:TextBox>
    
            <asp:AutoCompleteExtender ID="txtAutoCompleteforCompany_AutoCompleteExtender"
	            MinimumPrefixLength="1" TargetControlID="TextBox1" 
	            CompletionSetCount="10"CompletionInterval="100" 
	            ServiceMethod="GetCompanyList" 
	            ServicePath="../BAL/WebService1.asmx"
	            runat="server" OnClientItemSelected="setCompanyMasterID" 
	            CompletionListElementID="listPlacement">
            </asp:AutoCompleteExtender>




</asp:Content>




If Someone Could help me on this matter it could be a great help for me.
Thanks in Advance!!!
Posted
Updated 27-Sep-12 21:36pm
v2
Comments
I.explore.code 28-Sep-12 4:27am    
How come your web service is in BAL?? shouldn't it be in PAL i.e. where you web pages are i.e. your ASP.NET application.

 
Share this answer
 
Found it! you haven't got a space between these two attributes:

HTML
CompletionSetCount="10"CompletionInterval="100"


Change the above to:

HTML
CompletionSetCount="10" CompletionInterval="100"


See if this works.
 
Share this answer
 

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



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