CssStyleCollection.Remove 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 a style item from the CssStyleCollection of a control.
Overloads
Remove(String) |
Removes a style item from the CssStyleCollection of a control using the specified style key. |
Remove(HtmlTextWriterStyle) |
Removes a style item from the CssStyleCollection collection of a control using the specified HtmlTextWriterStyle enumeration value. |
Remove(String)
Removes a style item from the CssStyleCollection of a control using the specified style key.
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 string literal of the style item to remove.
Examples
The following example demonstrates how to use the Remove method to programmatically delete a CSS style from an HtmlSelect control.
<%@ 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.Style.Remove("font");
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>CssStyleCollection Remove Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Click the submit button to clear the font formatting.
<br />
<select id="FirstSelect"
style="font: 14pt Arial; background-color:Yellow; color:Blue;"
runat="server">
<option >option 1</option>
<option >option 2</option>
<option >option 3</option>
</select>
<input id="SubmitBtn"
value="Submit"
type="submit"
onserverclick="SubmitBtn_Click"
runat="server" /><br />
</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.Style.Remove("font")
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>CssStyleCollection Remove Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Click the submit button to clear the font formatting.
<br />
<select id="FirstSelect"
style="font: 14pt Arial; background-color:Yellow; color:Blue;"
runat="server">
<option >option 1</option>
<option >option 2</option>
<option >option 3</option>
</select>
<input id="SubmitBtn"
value="Submit"
type="submit"
onserverclick="SubmitBtn_Click"
runat="server" /><br />
</div>
</form>
</body></html>
See also
Applies to
Remove(HtmlTextWriterStyle)
Removes a style item from the CssStyleCollection collection of a control using the specified HtmlTextWriterStyle enumeration value.
public:
void Remove(System::Web::UI::HtmlTextWriterStyle key);
public void Remove (System.Web.UI.HtmlTextWriterStyle key);
member this.Remove : System.Web.UI.HtmlTextWriterStyle -> unit
Public Sub Remove (key As HtmlTextWriterStyle)
Parameters
The HtmlTextWriterStyle enumeration value to remove.
See also
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기