AttributeCollection.Remove(String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Removes an attribute from a server control's AttributeCollection object.
public:
void Remove(System::String ^ key);
public void Remove (string key);
member this.Remove : string -> unit
Public Sub Remove (key As String)
Parameters
- key
- String
The name of the attribute to remove.
Examples
The following example shows how to programmatically remove an attribute from an HTML server control's AttributeCollection object.
<%@ 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.Remove("Size");
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>AttributeCollection Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Make a selection:
<select id="FirstSelect"
size="10"
runat="server">
<option>This</option>
<option>That</option>
<option>Other</option>
</select>
<br/><br/>
<input type="submit"
id="SubmitBtn"
value="Remove Size Attribute"
onserverclick="SubmitBtn_Click"
runat="server"/>
</div>
</form>
</body>
</html>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub SubmitBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
FirstSelect.Attributes.Remove("Size")
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>AttributeCollection Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Make a selection:
<select id="FirstSelect"
size="10"
runat="server">
<option>This</option>
<option>That</option>
<option>Other</option>
</select>
<br/><br/>
<input type="submit"
id="SubmitBtn"
value="Remove Size Attribute"
onserverclick="SubmitBtn_Click"
runat="server"/>
</div>
</form>
</body>
</html>
Remarks
If the AttributeCollection object does not contain an attribute that has the specified key
, the collection remains unchanged. No exception is thrown.
Applies to
See also
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET