-
Feb 17th, 2011, 02:41 AM
#1
Thread Starter
Hyperactive Member
autocomplete not working
Hi,
I don't know what mistake i am doing... script manager in master page...
---------------------
Code:
//aspx Page--------------
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ MasterType TypeName="DOM_MasterPage" %>
<asp:TextBox ID="txtservicecode" runat="server"></asp:TextBox>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
ServicePath="~/App_Code/bills.cs"
ServiceMethod="GetServiceCode"
TargetControlID="txtservicecode"
MinimumPrefixLength="1" >
</cc1:AutoCompleteExtender>
//webservice CS-------------------------
[WebMethod]
[System.Web.Script.Services.ScriptMethod]
public List<string> GetServiceCode(string prefixText, int count)
{
SqlConnection connection = null;
try
{
connection = GetConnection();
}
catch (Exception e)
{
throw new Exception(e.InnerException.Message, e.InnerException);
}
try
{
DataSet objds = new DataSet();
string sql = "select name from claims_service_code where active_yn = 'Y' and name like '%" + prefixText+"'";
objds = DataFactory.ExecuteDataset(connection, CommandType.Text, sql);
List<string> cntcount = new List<string>(objds.Tables[0].Rows.Count);
if (count == 0)
{
count = 10;
}
foreach (DataRow objdr in objds.Tables[0].Rows)
{
string servicecode = objdr[0].ToString();
cntcount.Add(servicecode);
}
return cntcount;
}
catch (Exception ex)
{
throw ex;
}
}
-------------------------------------------------
Last edited by sagarpassion; Jan 22nd, 2013 at 08:37 AM.
Sagar
VB6, VB.net,C#,ASP, ASP.net MSSQL, MYSQL
-
Feb 18th, 2011, 02:45 AM
#2
Re: autocomplete not working
Hello,
I think you are going to have to provide us more information than you currently have. What does this:
Actually mean?
Are there any warning/errors on either the client or the server? Have to set a breakpoint in your server side code? If so, does it get hit? If so, have you stepped through the code?
Gary
-
Feb 18th, 2011, 04:05 AM
#3
Thread Starter
Hyperactive Member
Re: autocomplete not working
ohh dear gary i was waiting for your reply from last day....
error description:
Actually I haven't get any error. When i key press doesnt fire the webservice, this is the problem.
If I run webservice it works fine it giving me output. It means web service is fine.
Sagar
VB6, VB.net,C#,ASP, ASP.net MSSQL, MYSQL
-
Feb 18th, 2011, 06:33 AM
#4
PowerPoster
Re: autocomplete not working
the webmethod must be shared. I know in vb.net it is Public Shared Function ....
not sure what c# is.
-
Feb 19th, 2011, 09:27 AM
#5
Re: autocomplete not working
Hello,
I think the problem here is this:
Code:
ServicePath="~/App_Code/bills.cs"
Do you actually have a Web Service? i.e. a service with a .asmx extension, or are you trying to use a PageMethod on an ASPX page?
See the example on this page:
http://www.asp.net/ajax/ajaxcontrolt...ocomplete.aspx
Gary
-
Feb 20th, 2011, 11:21 PM
#6
Thread Starter
Hyperactive Member
Re: autocomplete not working
hi Gary there is actual web service dombill.asmx
I am ready to post entire code.
ASPX Page
Code:
<%@ Page Language="C#" MasterPageFile="~/DOM/MasterPage.master" AutoEventWireup="true" CodeFile="domregistration.aspx.cs" Inherits="DOM_domregistration" Title="Dom Bill Registration"%>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ MasterType TypeName="DOM_MasterPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<td colspan="100%">
<asp:TextBox ID="txttest" runat="server"></asp:TextBox>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
ServicePath="~/App_Code/dombill.cs"
ServiceMethod="GetServiceCode"
CompletionSetCount="20"
TargetControlID="txttest"
MinimumPrefixLength="1">
</cc1:AutoCompleteExtender>
</asp:Content>
WebService
Code:
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using DAO;
/// <summary>
/// Summary description for dombill
/// </summary>
///
[WebService(Namespace = "http://dom.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class dombill : System.Web.Services.WebService
{
public string strConnString;
public string strAMConnString;
public string strIAConnString;
#region General Methods
public SqlConnection GetConnection()
{
//strConnString = ConfigurationManager.ConnectionStrings["MyDB"].ConnectionString;
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MyDB"].ConnectionString);
connection.Open();
return connection;
}
#endregion
[WebMethod]
public List<string> GetServiceCode(string prefixText, int count)
{
SqlConnection connection = null;
try
{
connection = GetConnection();
}
catch (Exception e)
{
throw new Exception(e.InnerException.Message, e.InnerException);
}
try
{
DataSet objds = new DataSet();
string sql = "select name from service_code where active_yn = 'Y'";
objds = DataFactory.ExecuteDataset(connection, CommandType.Text, sql);
List<string> cntcount = new List<string>(objds.Tables[0].Rows.Count);
if (count == 0)
{
count = 10;
}
foreach (DataRow objdr in objds.Tables[0].Rows)
{
string servicecode = objdr[0].ToString();
cntcount.Add(servicecode);
}
return cntcount;
}
catch (Exception ex)
{
throw ex;
}
}
}
ASMX Page or service
Code:
<%@ WebService Language="C#" CodeBehind="~/App_Code/dombill.cs" Class="dombill" %>
Sagar
VB6, VB.net,C#,ASP, ASP.net MSSQL, MYSQL
-
Feb 20th, 2011, 11:22 PM
#7
Thread Starter
Hyperactive Member
Re: autocomplete not working
HI Nitesh,
If you see in webservice everything is public... Is there anything else to do?
Sagar
VB6, VB.net,C#,ASP, ASP.net MSSQL, MYSQL
-
Feb 21st, 2011, 02:17 AM
#8
Re: autocomplete not working
In which case, I believe the markup that you are using for the AutoComplete Extender is incorrect. You are referencing the .cs file, when you should be referencing the .asmx file. Take a look at the example that I linked to, and you should be able to get it working.
Gary
-
Feb 21st, 2011, 07:13 AM
#9
Thread Starter
Hyperactive Member
Re: autocomplete not working
Its working Gary...
In asmx file i have mention path = CodeBehind="~/App_Code/dombill.cs"
I have moved my dombill.cs file to Webservice folder and it start working. Previously it was in app_code folder.
one more question why we are mentioning 'CodeBehind="~/App_Code/dombill.cs"' if we are putting file in webservice folder??
Thanks for the showing me the way of correct path.
Sagar
VB6, VB.net,C#,ASP, ASP.net MSSQL, MYSQL
-
Feb 21st, 2011, 07:28 AM
#10
Re: autocomplete not working
Hello,
That really wasn't the fix that I was suggesting
You currently have this:
Code:
ServicePath="~/App_Code/dombill.cs"
And based on the example here:
http://www.asp.net/ajax/ajaxcontrolt...ocomplete.aspx
I was suggesting that this should look more like this:
Code:
ServicePath="AutoComplete.asmx"
Gary
-
Feb 21st, 2011, 10:15 AM
#11
Thread Starter
Hyperactive Member
Re: autocomplete not working
yes you are right Gary wat u suggesting was also rite...while doing RND of 5 hours i have chnage lot of things that time i have
Code:
ServicePath="~/App_Code/dombill.cs"
this instead of
Code:
ServicePath="AutoComplete.asmx"
right code is
Code:
ServicePath="AutoComplete.asmx"
ur suggestion was rite....
But real solution is
Code:
ServicePath="~/App_Code/dombill.cs"
on this path dombill.cs should be in appcode/webservice..
Sagar
VB6, VB.net,C#,ASP, ASP.net MSSQL, MYSQL
-
Feb 21st, 2011, 04:49 PM
#12
Re: autocomplete not working
Calling into the .cs file directly, although this might work, means that your WebService isn't acting "correctly" as a WebService. I would encourage you to reference the .asmx directly, rather than the code file.
Gary
-
Feb 21st, 2011, 11:30 PM
#13
Thread Starter
Hyperactive Member
Re: autocomplete not working
I am very sorry Garry... opening old thread again.
I dnt knw wat i put in the thread.
ServicePath="AutoComplete.asmx" = Corrected.
ServicePath="~/App_Code/dombill.cs" is actually codebehind of asmx file.
I dont know why i put in the thread.
It starts work when I change '~/App_Code/dombill.cs' To '~/App_Code/Web Service/dombill.cs'
Surprisingly dombill.cs is at following location = '~/App_Code/dombill.cs'
How this is working fine?
Last edited by sagarpassion; Jan 22nd, 2013 at 08:43 AM.
Sagar
VB6, VB.net,C#,ASP, ASP.net MSSQL, MYSQL
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|