IStyleSheetとは? わかりやすく解説

IStyleSheet インターフェイス

メモ : このインターフェイスは、.NET Framework version 2.0新しく追加されたものです。

スタイル ルール作成サポートするためにクラス実装する必要があるメソッド定義します

名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)
構文構文

解説解説
使用例使用例

IStyleSheetHeader 実装使用してプログラムによって新しいスタイル ルール作成しカスタム Style オブジェクト登録するコード例次に示します

コード例最初部分では、カスタム Style オブジェクトである labelStyle作成し現在の場所 (URL) に登録します次にlabel1 ラベルが MergeStyle メソッド呼び出しlabelStyle スタイルlabel1 ラベル適用します。

2 番目の部分では、もう 1 つカスタム Style オブジェクトである bodyStyle定義しプロパティ設定して新しいスタイル ルール作成します

メモメモ

このクラスは、主に、カスタム実装作成する開発者使用するためのものです。この例では、.NET Framework提供する実装示してます。

<%@ Page Language="VB" AutoEventWireup="true"
 CodeFile="istylesheetvb.aspx.vb" Inherits="istylesheetvb"
 %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html  >
<head id="head1" runat="server"
 />
  <body>
    <form id="form1" runat="server">
        <h1>IStyleSheet Example</h1>
        <asp:Label 
          id="label1" 
          runat="server">
        </asp:Label>
        <br /><br />
        <asp:Label 
          id="label2" 
          runat="server">
        </asp:Label>
    </form>
  </body>
</html>
<%@ Page Language="C#" AutoEventWireup="true"
 CodeFile="istylesheetcs.aspx.cs" Inherits="istylesheetcs" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html  >
<head id="head1" runat="server" />
  <body>
    <form id="form1" runat="server">
        <h1>IStyleSheet Example</h1>
        <asp:Label 
          id="label1" 
          runat="server">
        </asp:Label>
        <br /><br />
        <asp:Label 
          id="label2" 
          runat="server">
        </asp:Label>
    </form>
  </body>
</html>

前の例の Web ページ対す分離コード ファイル次に示します

public partial class istylesheetcs : System.Web.UI.Page
{
    protected void Page_Load(object sender,
 EventArgs e)
    {
        // Create a Style object to hold style rules to apply to a Label
 control.
        Style labelStyle = new Style();

        labelStyle.ForeColor = System.Drawing.Color.DarkRed;
        labelStyle.BorderColor = System.Drawing.Color.DarkBlue;
        labelStyle.BorderWidth = 2;

        // Register the Style object so that it can be merged with 
        // the Style object of the controls that use it.
        Page.Header.StyleSheet.RegisterStyle(labelStyle, null);

        // Merge the labelCssStyle style with the label1 control's
        // style settings.
        label1.MergeStyle(labelStyle);
        label1.Text = "This is what the labelCssStyle looks like.";


        // 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, null,
 "BODY");

        // Add text to the label2 control to see the label without 
        // the labelStyle applied to it.  
        label2.Text = "This is what the bodyStyle looks like.";
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

IStyleSheet メソッド


IStyleSheet メンバ




英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「IStyleSheet」の関連用語

IStyleSheetのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



IStyleSheetのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS