ASP.NET: Custom AutoCompleteTextBox WebContro…
2008-02-22 09:32:45来源:互联网 阅读 ()
" 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)));
}
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash
