欢迎光临
我们一直在努力

可输入的dropdownlist+服务器端的数据-ASP教程,数据库相关

建站超值云服务器,限时71元/月

在把桌面程序改为 web程序时, 原来程序中用到的一个infragistics的控件,既能输入又能下啦,下拉显示为一个table, 虽然infragistics也提供了这样的web control, 但在使用过程中出现了一些bug。设置也比较繁琐。于是只好自己写了。

不过没有写成控件,通用性比较差

1。在服务器端将可选择的值导在一个datagrid中, 设置这个datagrid的display = none

2. 再在服务器端设置datagrid的每个item的onlick值

for i = 0 to dgd.items.count – 1

dgd.items(i).attributes.add("onclick", "show(""" + dgd.items(i).cells(0).text.trim + """," + txt.clientid + ")")

dgd.items(i).attributes.add("onmouseover", "this.classname=sel;")

dgd.items(i).attributes.add("onmouseout", "this.classname=params;")

dgd.items(i).cssclass = "params"

next

这里必须设置在客户端点击某行时在那个控件现实什么值

3。还在服务器端设置点击的图片的客户端事件

img.attributes.add("onclick", "lstparams(" + txt.clientid + "," + dgd.clientid + ")")

显示哪个datagrid中的值在哪个textbox下

4. 在客户端javascript中复制要显示的隐藏的datagrid中的值到一个div中,并设置显示的位置

/<div id=divparams

style="display: none; z-index: 102; left: 288px; width: 200px; position: absolute; top: 264px; height: 115px"/>/</div/>

function lstparams(txtbox,dgd) { var x,y; var dd=document.all[divparams]; var dpar=document.all[dgd]; var e =document.all[txtbox]; var str; var y=e.offsettop+e.offsetheight; var x=e.offsetleft; while(e=e.offsetparent) { y+=e.offsettop; x+=e.offsetleft; }

str=dpar.innerhtml;

dd.innerhtml="/<table class=paramtb rules=all />"+str+"/</table/>";

with(dd.style) { left = x; top =y ; } }

客户端点击事件:

function show(value,ctr) { document.all[ctr].value=value; }

function hideparams() { var el=window.event.srcelement; if (el.id.indexof(btnlst)==-1) document.all[divparams].style.display=none; else { if( document.all[divparams].style.display==none) document.all[divparams].style.display=; else document.all[divparams].style.display=none; } }

window.document.attachevent("onclick",hideparams);

5。 要模仿得像dropdownlist要设置点击的图片紧靠在textbox旁

img id=btnlst style="z-index: 1;top:4px; left: -5px; position: relative" alt="" src="images/btn.gif" runat=server

这样就可以模仿一个可输入的dropdownlist下拉为一个table, 点中某行可以将要显示的值显示在输入框中

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 可输入的dropdownlist+服务器端的数据-ASP教程,数据库相关
分享到: 更多 (0)

相关推荐

  • 暂无文章