IStyleSheet.CreateStyleRule メソッド
アセンブリ: System.Web (system.web.dll 内)

Sub CreateStyleRule ( _ style As Style, _ urlResolver As IUrlResolutionService, _ selector As String _ )
Dim instance As IStyleSheet Dim style As Style Dim urlResolver As IUrlResolutionService Dim selector As String instance.CreateStyleRule(style, urlResolver, selector)

CreateStyleRule メソッドは、指定されたセレクタに対してスタイル ルールを作成します。複数のスタイル ルールを同じセレクタに対して作成することもできます。
urlResolver が null 参照 (Visual Basic では Nothing) の場合、現在の Page インスタンスの URL が使用されます。

IStyleSheet の Header 実装を使用して、新しい Style オブジェクトである bodyStyle を定義するコード例を次に示します。bodyStyle は CreateStyleRule を呼び出すことにより、現在の URL に追加されます。
<%@ 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"> Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) If Not Page.Header Is Nothing Then ' Create a Style object for the <BODY> section of the Web page. Dim bodyStyle As Style = New Style() bodyStyle.ForeColor = System.Drawing.Color.Blue bodyStyle.BackColor = System.Drawing.Color.LightGray ' Add the style to the header of the current page. Page.Header.StyleSheet.CreateStyleRule(bodyStyle, me, "BODY") ' Add text to the label2 control to see the style rules applied to it. label1.Text = "This is what the bodyStyle looks like." End If End Sub </script> <html > <head id="head1" runat="server" /> <body> <form id="form1" runat="server"> <h1>IStyleSheet Example</h1> <asp:Label id="label1" runat="server"> </asp:Label> </form> </body> </html>
<%@ 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"> void Page_Load(object sender, EventArgs e) { if (Page.Header != null) { // Create a Style object for the <BODY> section of the Web page. Style bodyStyle = new Style(); bodyStyle.ForeColor = System.Drawing.Color.Blue; bodyStyle.BackColor = System.Drawing.Color.LightGray; // Add the style to the header of the current page. Page.Header.StyleSheet.CreateStyleRule(bodyStyle, this, "BODY"); // Add text to the label2 control to see the style rules applied to it. label1.Text = "This is what the bodyStyle looks like."; } } </script> <html > <head id="head1" runat="server" /> <body> <form id="form1" runat="server"> <h1>IStyleSheet Example</h1> <asp:Label id="label1" runat="server"> </asp:Label> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からIStyleSheet.CreateStyleRule メソッドを検索する場合は、下記のリンクをクリックしてください。

- IStyleSheet.CreateStyleRule メソッドのページへのリンク