C#控件DropDownList下拉列表默认打开

c#中的控件DropDownList要实现默打开确实不容易,之前也是想过页面上的点击之后就打开了,那直接模拟点击不就行了,试过后大失所望,根本没有效果。

于是网上找到了一个例子能实现IE浏览器下的打开,具体实现看下面例子

<asp:DropDownList ID="ddlgsmc" runat="server" Height="20px" ></asp:DropDownList>

js中的代码

window.onload=function (){
                document.getElementById("ddlgsmc").focus();
                var WshShell = new ActiveXObject("Wscript.Shell");
                try {
                    WshShell.SendKeys("%{DOWN}");
                } catch (e) { }
                WshShell.Quit;
}

  

posted @ 2019-03-28 17:32  蓬鹏  阅读(1496)  评论(0编辑  收藏  举报