c#中的控件DropDownList要实现默打开确实不容易,之前也是想过页面上的点击之后就打开了,那直接模拟点击不就行了,试过后大失所望,根本没有效果。
于是网上找到了一个例子能实现IE浏览器下的打开,具体实现看下面例子
<asp:DropDownList ID="ddlgsmc" runat="server" Height="20px" ></asp:DropDownList>
js中的代码
window.οnlοad=function (){
document.getElementById("ddlgsmc").focus();
var WshShell = new ActiveXObject("Wscript.Shell");
try {
WshShell.SendKeys("%{DOWN}");
} catch (e) { }
WshShell.Quit;
}