[英]how to change aspx with javascript functions from aspx.cs?
我正在一個asp.net Web應用程序項目上,並且有一個使用javascript的下拉菜單按鈕:
<asp:Button ID="BtnPlant1" runat="server" Width="160px" BackColor="Transparent"
Height="40px" CssClass="buttonStyle" onmouseover="MM_showMenu(window.langT,0,40,null,'BtnPlant1');"
onmouseout=MM_startTimeout();/>
我有一個下拉列表,用於更改下拉菜單。
例如,當dropdownlist.SelectedItem.Text == "langE"
我想將onmouseover
更改為此:
onmouseover="MM_showMenu(window.langE,0,40,null,'BtnPlant1');"
// ^-- (langE, not langT)
我怎樣才能做到這一點? 任何想法? 謝謝...
您應該有jquery ...所以嘗試這樣的事情:
<asp:Button ID="BtnPlant1" runat="server" Width="160px" BackColor="Transparent"
Height="40px" CssClass="buttonStyle" onmouseover="showMenu()"
onmouseout=MM_startTimeout();/>
javascript:
function showMenu() {
if($('.dropdownlist').val() == "langE")
MM_showMenu(window.langE,0,40,null,'BtnPlant1');
else
MM_showMenu(window.langT,0,40,null,'BtnPlant1');
}
$('.dropdownlist').change(function() {
showMenu();
}
不是睾丸!
解決方案:
function showMenu() {
if($("#ddlistid option:selected").text() == "langE")
MM_showMenu(window.langE,0,40,null,'BtnPlant1');
else
MM_showMenu(window.langT,0,40,null,'BtnPlant1');
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.