Text Box auto scaling is achieved without using web Services

Source: Internet
Author: User

In the past, the AutoCompleteExtender function of Ajax was written to the WCF Service or Web Service data source. However, in a system, many text boxes want to use the AutoComplete function. We cannot write many services, such as small data. Is there an alternative? This is for sure. In the following example, Insus. NET implements the AutoCompete extender function of the text box without writing services.

First, you can obtain the number from the database. You can write an SQL statement or a stored procedure. The following describes how to obtain the domain user information, similar to the effect of the recipient input by Outlook.

Information in the [ActiveDirectoryInfo] Table is regularly synchronized with the Active Directory of the domain.
Copy codeThe Code is as follows:
Usp_ActiveDirectoryInfo_GetDisplayNameForService
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- ===================================================== ======
-- Author: Insus. NET
-- Create date: 2013-03-28
-- Description: Get dissplay name form web service
-- ===================================================== ======
Create procedure [dbo]. [usp_ActiveDirectoryInfo_GetDisplayNameForService]
(
@ PrefixText NVARCHAR (MAX ),
@ Count INT
)
AS
DECLARE @ w nvarchar (MAX) = @ PrefixText + '%'
EXECUTE ('select TOP ('+ @ Count +') [displayName] FROM [dbo]. [ActiveDirectoryInfo] WHERE [displayName] LIKE ''' + @ w + '''')

At the logic layer, we write a category to interact with the data layer:
Copy codeThe Code is as follows:
Using System;
Using System. Collections. Generic;
Using System. Data;
Using System. Linq;
Using System. Web;

/// <Summary>
/// Summary description for ActiveDirectoryInfo
/// </Summary>
Namespace Insus. NET
{
Public class ActiveDirectoryInfo
{
Businimap4 objbusinimap4 = new businimap4 ();

Public ActiveDirectoryInfo ()
{
//
// TODO: Add constructor logic here
//
}

Public DataTable GetDisplayName (string prefixText, int count)
{
Parameter [] parameter = {
New Parameter ("@ PrefixText", SqlDbType. NVarChar,-1, prefixText ),
New Parameter ("@ Count", SqlDbType. Int, 4, count)
};
Return objbusinimap4. GetDataToDataSet ("usp_ActiveDirectoryInfo_GetDisplayNameByPrefixText", parameter). Tables [0];
}
}
}

In the preceding category, an object is businworksheet.
Set ScriptManager
Copy codeThe Code is as follows:
<Asp: ScriptManager ID = "ScriptManager1" runat = "server"> </asp: ScriptManager>

Or ToolkitScriptManager
Copy codeThe Code is as follows:
<AjaxToolkit: ToolkitScriptManager ID = "ToolkitScriptManager1" runat = "server"/>

Pull to the webpage.

It is an html and cs program. There must be two lines of code before the method:
Copy codeThe Code is as follows:
[System. Web. Services. WebMethod]
[System. Web. Script. Services. ScriptMethod]


Effect:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.