Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET Ajax
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 27-Sep-12 21:31pm
Hesha769
Edited 27-Sep-12 22:36pm
v2
Comments
gladiatron at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Found it! you haven't got a space between these two attributes:
 
CompletionSetCount="10"CompletionInterval="100"

 
Change the above to:
 
CompletionSetCount="10" CompletionInterval="100"

 
See if this works.
  Permalink  

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

  Print Answers RSS
0 DamithSL 405
1 OriginalGriff 245
2 Sergey Alexandrovich Kryukov 207
3 Peter Leow 185
4 Afzaal Ahmad Zeeshan 154
0 OriginalGriff 7,460
1 DamithSL 5,519
2 Sergey Alexandrovich Kryukov 4,954
3 Maciej Los 4,936
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100