<%@ page language= "C #"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<script runat= "Server" >
protected void SubmitBtn_Click (object sender, EventArgs e)
{
Firstselect. Attributes.Add ("multiple", "True");
}
</script>
<title>attributecollection example</title>
<body>
<form id= "Form1" runat= "Server" >
<div>
Make a selection:
<select id= "Firstselect"
runat= "Server" >
<option>This</option>
<option>That</option>
<option>Other</option>
</select>
<br/><br/>
<input type= "Submit"
Id= "Submitbtn"
value= "Modify Attribute"
onserverclick= "SubmitBtn_Click"
runat= "Server"/>
</div>
</form>
</body>
Https://docs.microsoft.com/zh-cn/dotnet/api/system.web.ui.attributecollection.add?redirectedfrom=MSDN&view =netframework-4.7.2#system_web_ui_attributecollection_add_system_string_system_string_
Attributecollection.add (String, String) Method