AJAX :: AutoComplete Extender Web Service - Select Client Names From Sql Server Then Store Into Arraylist
Jul 26, 2010
I am not sure about writing the method in the web service. I'm trying to select the client names from sql server, then storing them into an arraylist. Finally, returning the array of names. This is my code:
I have a textbox in my form wich has an ajax autocomplete extender. I could load the list , my problem is i need to get the ID of the selected list item and based on the selected item load few controls. the following is my code
[Code]....
all i need is a way to get the selected value to the hidden field (hdnReceiverID) when i tried with text changed of the text box it doesnt give the value.
Is there another way to track the selected item change ?
web service method(getMainHeads) with parameter is not calling with auto complete text box extender(same method with out parameter is calling fine). My Service is
[System.Web.Script.Services. ScriptService] public class InvService : System.Web.Services.WebService { ItemMainHeadMsts objItemMainHeadMsts; DatabaseHelper objDataHelper; [WebMethod] public string[] GetMainHeads(string value) { List<string> oList = new List<string >(); objItemMainHeadMsts = new ItemMainHeadMsts (); objDataHelper = new DatabaseHelper (); objItemMainHeadMsts = ItemMainHeadMstBase.SelectByFieldAuto("IMHDesc" , value); foreach (ItemMainHeadMst mainHead in objItemMainHeadMsts) { oList.Add(mainHead.IMHDesc); } return oList.ToArray();..........................
public class WebService : System.Web.Services.WebService { MySql.Data.MySqlClient.MySqlCommand cmd = new MySqlCommand(); MySql.Data.MySqlClient.MySqlConnection con = new MySqlConnection(); //MySqlDataAdapter da = new MySqlDataAdapter(); MySqlDataReader dr; public WebService () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public string[] GetCountryInfo(string prefixText) { int count = 10; string sql = "Select * from tbl_patientmaster Where P_NAME like '" + @prefixText + "%'"; con.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["HMSDBConnectionString"].ToString(); con.Open(); MySql.Data.MySqlClient.MySqlDataAdapter da = new MySql.Data.MySqlClient.MySqlDataAdapter(sql, con); da.SelectCommand.Parameters.Add("@prefixText", MySql.Data.MySqlClient.MySqlDbType.VarChar, 50).Value = prefixText + "%"; System.Data.DataTable dt = new System.Data.DataTable(); da.Fill(dt); string[] items = new string[dt.Rows.Count]; int i = 0; foreach (System.Data.DataRow dr in dt.Rows) { items.SetValue(dr["P_NAME"].ToString(), i); i++; } return items; }
I am using AutoComplete ASP.NET AJAX Control toolkit AutoCompleteExtender control When I am using my web service as Service Path, its not working.my web services code below
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using System.Data.SqlClient; using System.Data; using System.Web.Script.Services; namespace OnlineSalesGrid { /// <summary> /// Summary description for sample /// </summary> [WebService(Namespace = [URL]] [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 sample : System.Web.Services.WebService { [WebMethod] public static string[] GetCompletionList(string prefixText, int count) { List<string> returnData = new List<string>(); SqlConnection con = new SqlConnection("Data Source=CARPATHIA\SQLEXPRESS;Initial Catalog=OnlinesaleGrid;Persist Security Info=True;User ID=sa;Password=c0rpusdata"); string sql = "select Customer_Name from Customer_Master where Customer_Name like '%" + prefixText + "%'"; SqlCommand cmd = new SqlCommand(sql, con); con.Open(); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { returnData.Add(reader["Customer_Name"].ToString()); } return returnData.ToArray(); } [WebMethod] public static string[] GetCompletionList1(string prefixText, int count) { List<string> returnData = new List<string>(); SqlConnection con = new SqlConnection("Data Source=CARPATHIA\SQLEXPRESS;Initial Catalog=OnlinesaleGrid;Persist Security Info=True;User ID=sa;Password=c0rpusdata"); string sql = "select Customer_Code,Customer_Name from Customer_Master where Customer_Code like '%" + prefixText + "%'"; SqlCommand cmd = new SqlCommand(sql, con); con.Open(); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { returnData.Add(reader["Customer_Code"].ToString()); } return returnData.ToArray(); } } }
i want to create a arraylist which will able to store user info like (username,machineIP,port ) for each user in the list & retrive this data when needed . any one tell me how i can do it or any alternative way without database or xml file.
I am coming across one problem with auto complete extender in my application, problem seems to simple but i can't find any satisfactory solution. In one form, i have set auto complete extender on one text box, i have set one web service, in which one function is there, which fetches existing records from db, on first load, if i write releavent words with that of db, i can't see the extender, but if once either i minimize the page or give tab despite AutoPostBack property of text box is false, then after writing something in text box shows me the extender.
Here are the properties of both text box and extender
Iam getting an array of list from database to client side(javascript array).Now my aim to place those values in a div one by one and that div should attach to the textbox similar to Autocomplete extender.
I implemented autocomplete extender,functionality is working great but my issue is with CSS.It works as expected in Firefox(it applys all stylesheets perect) but in IE it is not behaving as expected it is showing the list about 10 pixels left to the text box.
googled couple of things but none of them were working for me.
i have installed AjaxControlToolkit for framework 3.5 . my application is in virtual folder on the server which has Autocomplete Extender control, when i browse, control is not returning any list nor any error message. it is working fine in the localhost, is it because of the subfolder or any other reason i dont understand
I'm yet another programmer who find out that AJAX autocomplete extender doesn't work although I've searched several pages and saw where the biggest problems occur.I'm using ASP.NET 2.0 and AJAX for the same version. Few months ago I've included modalPopupExtender in to the same project and it's working fine.However with AutoCompleteExtender have no luck..ASPX page:
[Code]....
and web service:
[Code]....
I was using this site for reference:ttp://dotnetslackers.com/Community/blogs/kaushalparik/archive/2008/06/06/autocomplete-textbox-using-ajax-autocompleteextender-from-database.aspxBut when I type something in textbox nothing happenes. However in IE8 I got message that there is script error.
In my recent project i have used auotcomplete extender. it work well with simple textbox
Now i want to use it with gridview , in my application for fill product details for any order i have used gridview if user wants to add multiple products so by making class create list of objects of that class and bind to gridview i am able to add row. in that row one field stock code now on that i want to use autocomplete extender as per below code
I am tring to use Jquery autocomplete into my asp.net 2.0 application, I have all necessary file in place, I tried to worked on , but it seems like this is not working,can some one tell me that is asp.net 2.0 application without using AJAX toolkit works with Jquery autocomplete or it does not work?Note: this is plain asp.net 2.0 web application, it is not using AJAX.
I have used autocomplete extender in my web application. It works perfectly on localhost, but when i try to access from different machine its not working.
I'm using Sys.UI.DataView and i have input of type text. I bind this input using live binding syntax and it works, but i want to add to this input autocomplete funcionallity.The problem is that autocomplete extender needs server side asp:TextBox and i can't find how to implement livebindng on this server control...
i need to pass two parameter in a autocomplete extender.below is my code and here i pass one parameter for autocomplete extender in web service.
[Code]....
here i pass a parameter :prefixtext.but in this query i need to pass one more parameter.i.e in that query one more condition i need like finanicial year. like where upper(reg_no) like @prefix and adm_fnyr=@fnyr.
so how can i pass and execute like this.i mean i need those reg_no which not in hreadmission table in same finanical year.
I am using VB 2008 and the ajax tool kit trying to get the autocomplete working. I have been looking at the asp.net video tutorials, but for the life of me - its not. Here is the code:
I am using autocomplete extender in my project with the external webservice. The problem what I am facing is I need to pass credentials to connect to the webservice, as this service is hosted in different domain.
We have used the ajax toolkit auto complete extender in an intranet app which uses Windows authentication. The auto complete uses a static page method in the page code behind to get the results. Even though the page containing the auto complete is authenticated by the server and the asp.net session id set in the cookie, the initial requests from the auto complete result in 401.1 and after few attempts result in a 200. This irritates the users of the app. Also later on there are 401.1 happening intermittently among the various 200 there by affecting the responses.
I have verified these responses by using Microsoft Network Monitor,Fiddler and Firebug. Also these entries are present in IIS logs. I tried to implement the same with a script service but that too gives same issues. Our site has lots of ajax features and controls and everything is working fine, only this issue is there.
i m using Autocomplete Extender and while retreving i want both Name and ID (i.e Two Strings ) And while Clicking Student Name i want to get ID from autocomplete extender itself and paste into another textbox thout Javascript.