Skip to main content

AJAX AUTOCOMPLETED

Code for AJAX AUTOCOMPLETED

----------------.aspx--------------

<asp:TextBox ID="txt_Narration" runat="server" Width="200px" OnTextChanged="txt_Narration_TextChanged"
AutoPostBack="true">
</asp:TextBox>&nbsp;
<div id="div_NARRATION">
</div>
<cc1:AutoCompleteExtender runat="server" ID="AutoComplete_NARRATION" BehaviorID="autoCompleteNARRATION"
TargetControlID="txt_Narration" ServicePath="~/webservices/CommonWebService.asmx"
ServiceMethod="Get_Narration" MinimumPrefixLength="1" CompletionInterval="10"
EnableCaching="true" CompletionSetCount="12" CompletionListCssClass="AutoExtender"
CompletionListItemCssClass="AutoExtenderList" CompletionListHighlightedItemCssClass="AutoExtenderHighlight"
CompletionListElementID="div_NARRATION">
</cc1:AutoCompleteExtender>

.CSS

.AutoCompleteExtender_CompletionList
{
font-size: small;   
visibility:hidden;
padding : 1px;
Height:230px;
width:250px;
z-index:5000;
cursor:default;
margin:0px!important;
border:buttonshadow;
list-style-type:none;
overflow:auto;
text-align:left;
border-width:1px;
border-style:solid;
border-color:Maroon;
}

.AutoExtender
{

font-family: Verdana, Helvetica, sans-serif;
font-size: .8em;
font-weight: normal;
border: solid 1px #006699;
line-height: 20px;
padding: 10px;
background-color: White;
margin-left:0px;
z-index:5000;
}
.AutoExtenderList
{
border-bottom: dotted 1px #006699;
cursor: pointer;
color: Maroon;
z-index:5000;
}
.AutoExtenderHighlight
{
color: White;
background-color: #006699;
cursor: pointer;
z-index:5000;
}
#divwidth
{
z-index:500;
width: 200px !important;  
text-align:Left; 
}
#divwidth div
{
z-index:500;
text-align:Left;
width: 200px !important;  

}


.webservices

using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data;
using System.Configuration;
using System.Diagnostics;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Web.Script.Services;
using System.Xml;
using System.Collections.Generic;
/// <summary>
/// Summary description for CommonWebService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]

ConnectionStringSettings css = ConfigurationManager.ConnectionStrings["cnnGPTERP_IBM"];
SqlConnection sqlcnGPTERP;
SqlDataAdapter da;
DataTable dt;








[WebMethod]
public string[] Get_Narration(string prefixText)
{
//int count = 10;
sqlcnGPTERP = new SqlConnection(css.ConnectionString);
string sql = "select  narr_code, narrat_name from narration  where  (narrat_name like @prefixText or narr_code like @prefixText) order by  narrat_name";
SqlDataAdapter da = new SqlDataAdapter(sql, sqlcnGPTERP);
da.SelectCommand.Parameters.Add("@prefixText", SqlDbType.VarChar, 50).Value = prefixText + "%";
DataTable dt = new DataTable();
da.Fill(dt);
string[] items = new string[dt.Rows.Count];
int i = 0;
foreach (DataRow dr in dt.Rows)
{
items.SetValue(dr["narrat_name"].ToString() + " { " + dr["narr_code"].ToString() + " }", i);
i++;
}
return items;
    }

Comments

Popular posts from this blog

Editing Child GridView in Nested GridView

Editing Child GridView in Nested GridView In this article we will explore how to edit child gridview in the nested gridview.   Let''s write some code. Step 1:  Add scriptmanager in the aspx page. < asp : ScriptManager   ID ="ScriptManager1"   runat ="server"   EnablePageMethods ="true"> </ asp : ScriptManager > Step 2:  Add below stylesheet for modal popup. < style   type ="text/css">        .modalBackground        {              background-color : Gray;              filter : alpha(opacity=80);              opacity : 0.5;       }        .ModalWindow        {     ...

Hierarchical GridView in ASP.NET with AJAX, JQuery implementation - Part 1

Previously I had blogged some post related to showing two grids in hierarchical way. For example - when I need to show an invoice reports on the screen, the user requesting to show the list of invoices at initial time and they can drill down the details of item details of each invoice by clicking on respective row. The implementations can be in multiple ways, but I had blogged the implementation with AJAX and without AJAX using Java script on ASP.NET page. Below are the URLs of the same – Hierarchical GridView in ASP.NET Hierarchical GridView in ASP.NET with AJAX, Javascript implementation In this post I am taking the same requirements done before and enhance with some additional functionality as per readers expectations. The requirement on this implementation will be – The page should show a Grid View with list of Orders with Expand icon on the first column. On click of expand icon on each row, the Order Details of the Order must be fetched from the database ...

Scrollable Gridview With fixheader using JQuery in Asp.net

Scrollable Gridview With fixheader using JQuery in Asp.net Introduction: In this article I will explain how to implement scrollable gridview with fixed header in asp.net using JQuery.  Description:  In Previous posts I explained lot of articles regarding Gridview. Now I will explain how to implement scrollable gridview with fixed header in asp.net. I have one gridview that contains lot of records and I used  paging for gridview  but the requirement is to display all the records without paging. I removed paging at that time gridview occupied lot of space because it contains more records to solve this problem we implemented scrollbar.  After scrollbar implementation if we scroll the gridview we are unable to see Gridview header.   To implement Scrollable gridview with fixed header I tried to implement concept with css and JavaScript but there is no luck because maintaining fixed header working in IE but not in Mozilla and vice versa to ...