手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>网络编程>Asp.Net编程>列表

ASP.NET: Custom AutoCompleteTextBox WebControl [With Source Code]

来源:互联网 作者:west263.com 时间:2008-02-22
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!

" return retMatches;\r\n",
" }\r\n",
"\r\n",
" function __DoAutoComplete(oEvent, id)\r\n",
" {\r\n",
" var oTextbox = document.getElementById(id '_textBox');\r\n",
" var frame = document.getElementById(id '_autoCompleteFrame');\r\n",
" var arrValues = document[id '_data'];\r\n",
" \r\n",
" switch (oEvent.keyCode) \r\n",
" {\r\n",
" case 38: //up arrow \r\n",
" case 40: //down arrow\r\n",
" case 37: //left arrow\r\n",
" case 39: //right arrow\r\n",
" case 33: //page up \r\n",
" case 34: //page down \r\n",
" case 36: //home \r\n",
" case 35: //end \r\n",
" case 13: //enter \r\n",
" case 9: //tab \r\n",
" case 27: //esc \r\n",
" case 16: //shift \r\n",
" case 17: //ctrl \r\n",
" case 18: //alt \r\n",
" case 20: //caps lock\r\n",
" case 8: //backspace \r\n",
" case 46: //delete\r\n",
" return true;\r\n",
" break;\r\n",
" \r\n",
" default:\r\n",
" textboxReplaceSelect(oTextbox, String.fromCharCode(isIE ? oEvent.keyCode : oEvent.charCode));\r\n",
" var iLen = oTextbox.value.length;\r\n",
"\r\n",
" var sMatches = autocompleteMatch(oTextbox.value, arrValues);\r\n",
"\r\n",
" if (sMatches.length > 0)\r\n",
" {\r\n",
" var arrMatches = sMatches.split(',');\r\n",
" oTextbox.value = arrMatches[0];\r\n",
" textboxSelect(oTextbox, iLen, oTextbox.value.length);\r\n",
" \r\n",
" if (arrMatches.length > 1)\r\n",
" {\r\n",
" frame.style.display = 'inline';\r\n",
" frame.height = '100';\r\n",
" \r\n",
" frame.contentWindow.document.body.innerHTML = '';\r\n",
" for (var i = 0; i < arrMatches.length; i )\r\n",
" {\r\n",
" frame.contentWindow.document.body.innerHTML = '<div style=\"width: 100%; cursor: default\" onmouseover=\"this.style.backgroundColor=\\'#316AC5\\'; this.style.color=\\'white\\';\" onmouseout=\"this.style.backgroundColor=\\'\\'; this.style.color=\\'black\\';\" onclick=\"parent.document.getElementById(\\'' id '_textBox\\').value = this.innerHTML\">' arrMatches[i] '</div>';\r\n",
" }\r\n",
" \r\n",
" frame.contentWindow.document.body.style.backgroundColor = 'white';\r\n",
" frame.contentWindow.document.onclick = function() { document.getElementById(id '_autoCompleteFrame').style.display = 'none'; };\r\n",
" } \r\n",
" } \r\n",
" \r\n",
" return false;\r\n",
" } \r\n",
" }\r\n",
"</script>\r\n",
"");
Page.ClientScript.RegisterClientScriptBlock(typeof(string), "__DoAutoComplete", script);
}

if (!Page.ClientScript.IsClientScriptBlockRegistered(MakeUniqueID("data")))
{
Page.ClientScript.RegisterClientScriptBlock(typeof(string), MakeUniqueID("data"), string.Format("<script language=\"javascript\" type=\"text/javascript\">document.{0}_data = {1}</script>", MakeUniqueID(null), ToJsStringArray(AutoCompleteData)));
}

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!