auto complete with ajaxcontroltoolkit and ado.net
-
hello to all i have a problem with the program that see in below; this program has not any syntax error but doesn't work; i thank you if help me.:rose: Default.aspx page:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server"></form>
</body>
</html>Default.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{}
}
in .asmx file
<%@ WebService Language="C#" CodeBehind="~/App_Code/AutoComplete.cs" Class="AutoComplete" %>
in .asmx code behind file
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Configuration;/// /// this WebService is designed for autocomplete with ajaxControlToolkit and ADO.Net
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to -
hello to all i have a problem with the program that see in below; this program has not any syntax error but doesn't work; i thank you if help me.:rose: Default.aspx page:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server"></form>
</body>
</html>Default.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{}
}
in .asmx file
<%@ WebService Language="C#" CodeBehind="~/App_Code/AutoComplete.cs" Class="AutoComplete" %>
in .asmx code behind file
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Configuration;/// /// this WebService is designed for autocomplete with ajaxControlToolkit and ADO.Net
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service toFor parameter fields you should add prefix
@
, like belowYa Rasoolallah wrote:
string query = "select \* from tbl\_users where username like **@**username"; SqlCommand cm = new SqlCommand(query,cn); cm.Parameters.AddWithValue("**@**username","N%"+prefixT ext+"%");
thatraja
Code converters | Education Needed No thanks, I am all stocked up. - Luc Pattyn When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is - Henry Minute
-
For parameter fields you should add prefix
@
, like belowYa Rasoolallah wrote:
string query = "select \* from tbl\_users where username like **@**username"; SqlCommand cm = new SqlCommand(query,cn); cm.Parameters.AddWithValue("**@**username","N%"+prefixT ext+"%");
thatraja
Code converters | Education Needed No thanks, I am all stocked up. - Luc Pattyn When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is - Henry Minute
thanks:rose: my friend , still does not work. why? :(: test it please.
-
thanks:rose: my friend , still does not work. why? :(: test it please.
I don't think you need N in below line
cm.Parameters.AddWithValue("**@**username","N%"+prefixText+"%");
Debug your code & make sure you get data in SqlDataReader
dr
(below line)while (dr.Read())
Before that make sure you have data in your database table tbl_users. I think you tried example from this article[^] so make sure you didn't miss any steps mentioned there.
thatraja
Code converters | Education Needed No thanks, I am all stocked up. - Luc Pattyn When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is - Henry Minute
-
I don't think you need N in below line
cm.Parameters.AddWithValue("**@**username","N%"+prefixText+"%");
Debug your code & make sure you get data in SqlDataReader
dr
(below line)while (dr.Read())
Before that make sure you have data in your database table tbl_users. I think you tried example from this article[^] so make sure you didn't miss any steps mentioned there.
thatraja
Code converters | Education Needed No thanks, I am all stocked up. - Luc Pattyn When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is - Henry Minute
hello the problem is not from @ or N and etc... my program doesn't have any syntax error but doesn't work not at all. please debug my program to see why not to work?thanks.:rose::rose: i worked from that example link that you said step by step exactly.
-
hello to all i have a problem with the program that see in below; this program has not any syntax error but doesn't work; i thank you if help me.:rose: Default.aspx page:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server"></form>
</body>
</html>Default.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{}
}
in .asmx file
<%@ WebService Language="C#" CodeBehind="~/App_Code/AutoComplete.cs" Class="AutoComplete" %>
in .asmx code behind file
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Configuration;/// /// this WebService is designed for autocomplete with ajaxControlToolkit and ADO.Net
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service toI have used many time auto complete Extender. I check out your code behind file.
[WebMethod]
public static string[] City(string prefixText, int count, string contextKey)
{DataTable dt = new DataTable(); dt = Bal\_BindingData.\_city(prefixText);
//_city is dataTable type function with the string type parameter.just add the String Contextkey in your GetCompletionList method.
string\[\] movies = new string\[dt.Rows.Count\]; for (int i = 0; i < dt.Rows.Count; i++) { movies\[i\] = dt.Rows\[i\]\["City"\].ToString(); } return movies; }
i think you forgot string Contextkey Parameter in GetCompletionList method. don't confused my with code i have used three tire technique. I hope your problem has been solved. :laugh: jsb