在前台写不管用,WHY!!!
<%@ 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>
------解决方案--------------------写在CS里,在TEXT里是当字符串处理的
------解决方案--------------------前台直接赋值绑顶是不行的
大不了你写成一个方法再来绑
------解决方案--------------------要是不想在后台处理
干脆就写个javascript呢
<asp:Label ID= "Label1 " runat= "server "
Text= ' <script> var a=document.getElementById( "DropDownList1 ").value;document.write(a); </script> '>
</asp:Label>
绝对可以