簡體   English   中英

如何在clientSide和ServerSide中使用selectedIndexChanged下拉列表

[英]How use selectedIndexChanged dropdownlist in clientSide and ServerSide

如何在clientSide和ServerSide中使用asp.net下拉列表中的selectedIndexChanged?

在客戶端我想要調用javascript函數!

<script type="text/javascript">
function changeCursor() {
    document.body.style.cursor="progress";
}
</script>

<asp:DropDownList ID="DropDownSubject" runat="server" DataTextField="Word" AutoPostBack="True" OnSelectedIndexChanged="SelectedChange">
</asp:DropDownList>

SelectedChange是客戶端中的函數名稱!

感謝幫助!

在下拉列表的onchange事件中添加客戶端函數名稱,如下所示:

<asp:DropDownList ID="DropDownSubject" runat="server" DataTextField="Word" 
      AutoPostBack="True" OnSelectedIndexChanged="SelectedChange" 
      onchange="changeCursor()">
</asp:DropDownList>

在HTML(.aspx)中

<asp:DropDownList ID="DropDownSubject" runat="server" DataTextField="Word" AutoPostBack="True" 
         OnSelectedIndexChanged="SelectedChange" onchange="YourChangeFun(this);">
</asp:DropDownList>

在javascript中

<script type="text/javascript">
      function YourChangeFun(ddl)
      {
         alert(ddl.selectedIndex);
      }
</script>

首先更改autopostback =“false”並給出onchange =“js function()”並刪除所選的索引更改事件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM