<head runat="server"> <title>无标题页</title> <mce:script type = "text/javascript" language = "javascript"><!-- function showSelection() { var select = document.getElementById('list'); if(select.selectedIndex >= 0) { var option = select.options[select.selectedIndex]; var msg = '你选择id是' + option.text; alert(msg); } } // --></mce:script> </head> <body> <form id="form1" runat="server"> <div> <asp:DropDownList ID="list" runat="server" DataSourceID="SqlDataSource1" DataTextField="UserID" DataValueField="UserID" > </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:database %>" SelectCommand="SELECT [UserID] FROM [LoginUser]"></asp:SqlDataSource> </div> </form> </body> 在page_load中添加 list.Attributes.Add("onchange", "showSelection();");