2017-08-09 5 views

答えて

0

ASPX:

<body onload="Prepend()"> 
<asp:DropDownList ID="ddlnames" runat="server"DataTextField="Id" DataValueField="Id"></asp:DropDownList> 
</body> 

Javascriptを:

function Prepend(){ 

      var option = document.createElement("option"); 
      option.text = "111"; 
      option.value = "3"; 
      option.selected=true; 

      var parent = document.getElementById("<%=ddlnames.ClientID %>") 
      parent.insertBefore(option, parent.firstChild); 

} 
関連する問題