<%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:dropdownlist ID="Dropdownlist1" runat="server"><asp:ListItem Text="ddddd" Value="dfd"/> </asp:dropdownlist>
</div>
<asp:Label ID="Label1" runat="server" Text='<%=this.Dropdownlist1.SelectedValue%>'></asp:Label>
</form>
</body>
根本不被解释。
查看生成HTML为:
<span id="Label1"><%=this.Dropdownlist1.SelectedValue%></span>
</html>
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:dropdownlist ID="Dropdownlist1" runat="server"><asp:ListItem Text="ddddd" Value="dfd"/> </asp:dropdownlist>
</div>
<asp:Label ID="Label1" runat="server" Text='<%=this.Dropdownlist1.SelectedValue%>'></asp:Label>
</form>
</body>
根本不被解释。
查看生成HTML为:
<span id="Label1"><%=this.Dropdownlist1.SelectedValue%></span>
</html>
干脆就写个javascript呢
<asp:Label ID="Label1" runat="server"
Text='<script>var a=document.getElementById("DropDownList1").value;document.write(a);</script>'></asp:Label>绝对可以