我想使用AjaxToolKit的dropdownlistextender构造下拉列表。 我有以下的标记:如何使用Dropdown Extender触发OnSelectedIndexChanged事件
<asp:Label ID="ddTest" runat="server" Text="Transactions" Width="300px" BorderColor="#C0C0C0" CssClass="selecter"/>
<ajaxToolkit:DropDownExtender runat="server" ID="ddeSections"
TargetControlID="ddTest" DropDownControlID="panelItems" HighlightBackColor="Silver"
DropArrowBackColor="white" HighlightBorderColor="Silver"/>
及以下的 “名单” 的项目:
<table runat="server" id="ctlOptions" class="options" cellspacing="2" cellpadding="2" border="1">
<tr><td class="item" onmouseover="mouseOver(this)" onmouseout="mouseOut(this)" onclick="clickIt(this)">Transactions</td></tr>
<tr><td class="item" onmouseover="mouseOver(this)" onmouseout="mouseOut(this)" onclick="clickIt(this)">The second option</td></tr>
<tr><td class="item" onmouseover="mouseOver(this)" onmouseout="mouseOut(this)" onclick="clickIt(this)">The third option</td></tr>
<tr><td class="item" onmouseover="mouseOver(this)" onmouseout="mouseOut(this)" onclick="clickIt(this)">The fourth option</td></tr>
<tr><td class="item" onmouseover="mouseOver(this)" onmouseout="mouseOut(this)" onclick="clickIt(this)">The fifth option</td></tr>
</table>
我的JavaScript看起来像这样:
function mouseOver(obj) {
if (obj) obj.className = 'itemOver';
}
function mouseOut(obj) {
if (obj) obj.className = 'item';
}
其中项目和itemOver是适当样式的CSS类。 问题是我想要我的onClick点击事件触发服务器上的SelectedIndexChanged -type事件。 我曾尝试使用此功能:
function clickIt(obj) {
var ddTest = document.getElementById("ctl00_ContentPlaceHolder1_ddTest");
var selVal = '';
if (ddTest) {
selVal = obj.firstChild.nodeValue;
ddTest.firstChild.nodeValue = selVal;
__doPostBack('<%=ddSections.ClientID %>', '');
}
}
ddSections是asp:Dropdown
其OnSelectedIndexChanged事件我试图触发。
这会触发页面级回发,但不会触发ddSections_SelectedIndexChanged服务器端方法,我想要触发。顺便说一下,ddSections将被隐藏。
请您提供一些建议。 我花了三天的时间试图找出这个问题,并且空手而归。 为了便于阅读,请随意重新格式化。 在此先感谢。