TextBox输入值自动获取后台匹配值
来源:互联网 发布:mac 无法连接网络 编辑:程序博客网 时间:2024/05/21 04:26
AjaxPro.NET实现TextBox智能获取服务端数据功能
AjaxPro.NET是一个优秀的Ajax框架, 在实际应用中只要添加其DLL引用并进行简单的配置,
即可以非常方便的在客户端直接调用服务端方法, 实现验证目的.
效果图显示:
前台调用代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AutoQueryTextBox.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>AutoQueryTextBox</title> <script language="javascript" src="lookup.js"></script><script language="jscript">mainLoop = function () { val = escape(queryField.value); if (lastVal != val) { var response = _Default.GetSearchItems(val); showQueryDiv(response.value); lastVal = val; } setTimeout('mainLoop()', 100); return true;} </script></head><body > <form id="form1" runat="server"> <div> <asp:Panel ID="Panel1" runat="server" BackColor="#C0C0FF" Font-Bold="True" Font-Overline="False" Font-Size="XX-Large" Height="37px" Width="475px">AutoQueryTextBox</asp:Panel> <br /> <hr align="left" style="width: 473px" /> <br /> 输入查询字串: <asp:TextBox ID="txSearch" runat="server" Width="134px"></asp:TextBox> <br /> <br /> </div> <script language="jscript"> InitQueryCode("" + '<%= txSearch.ClientID %>' + ""); </script> </form></body></html>
后台方法调用:
using System;using System.Data;using System.Configuration;using System.Web;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.Collections;using AjaxPro;public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Utility.RegisterTypeForAjax(typeof(_Default)); } [AjaxMethod()]// or [AjaxPro.AjaxMethod] public ArrayList GetSearchItems( string strQuery ) { //生成数据源 ArrayList items = new ArrayList(); items.Add("Codefans.net"); items.Add("code"); items.Add("cso"); items.Add("abcdefg"); items.Add("cso"); items.Add("ajax"); items.Add("236"); items.Add("qzone"); items.Add("123"); items.Add("5678.com"); items.Add("www.baidu.com"); items.Add("aspx.net"); //筛选数据 ArrayList selectItems = new ArrayList(); foreach( string str in items ) { if (str.ToUpper().IndexOf(strQuery.ToUpper()) == 0) { selectItems.Add(str); } } return selectItems; } }
来源于:http://www.codefans.net
案例下载地址1:http://download.csdn.net/detail/lovegonghui/9177325
案例下载地址2:http://down.51cto.com/data/2105139
0 0
- TextBox输入值自动获取后台匹配值
- TextBox 自动匹配扩展
- TextBox获取输入焦点时自动全选的实现方法
- Easyui的easyui-textbox输入框失焦事件获取输入值错误问题
- 前台只允许js改变TextBox值,且可后台获取
- TextBox属性设置为只读后台获取不到值的问题
- TextBox属性设置为只读后台获取不到值的问题
- Asp.net TextBox值改变了 但后台获取的值未变
- TextBox自动匹配,自动完成,AutoCompleteCustomSource
- 后台读取绑定控件中的TextBox值
- js获取中文拼音,Select自动匹配字母获取值
- easyui Multiline TextBox 获取值
- TextBox禁止输入 后台可读可写
- js 在TEXTBOX填写数据后自动传TEXTBOX值
- 自动匹配输入框
- AspxCombobox自动匹配输入
- 自动输入匹配
- 动态加载Textbox并取得输入值
- Android Studio 发生 Couldn't load jpush175 from loader dalvik.system.PathClassLoader 错误
- 使用iSCSI存储时报错(openfiler模拟)
- Yen-j 嚴爵 [ 一直給 Give ] 相信官方版
- IOS开发之格式化日期时间
- office 2010 PPT 中添加GIF动画
- TextBox输入值自动获取后台匹配值
- Java中部分关键字
- 【物联网】OpenWrt OpenWRT的源码下载及目录结构
- UITabBarController用法
- 图像处理 图像切割
- onAttachedToWindow()在整个Activity生命周期的位置及使用 .
- jquery 评分插件 juqer raty
- error C3861: “setw”: 找不到标识符
- iOS 9 学习系列:UIStack View