WebControl クラスとは? わかりやすく解説

WebControl クラス

System.Web.UI.WebControls 名前空間すべてのコントロールに共通のメソッドプロパティおよびイベント定義する基本クラスとして機能します

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

<ThemeableAttribute(True)> _
Public Class WebControl
    Inherits Control
    Implements IAttributeAccessor
[ThemeableAttribute(true)] 
public class WebControl : Control, IAttributeAccessor
[ThemeableAttribute(true)] 
public ref class WebControl : public
 Control, IAttributeAccessor
/** @attribute ThemeableAttribute(true) */ 
public class WebControl extends Control implements
 IAttributeAccessor
ThemeableAttribute(true) 
public class WebControl extends
 Control implements IAttributeAccessor
解説解説

WebControl クラスには、すべての Web サーバー コントロール共通するプロパティメソッド、およびイベント用意されています。このクラス定義されプロパティ設定することによって、Web サーバー コントロール外観動作制御できます。たとえば、コントロール背景色フォントの色を制御するには、BackColor プロパティと ForeColor プロパティそれぞれ設定します境界線表示できるコントロールで、境界線の幅、境界線スタイル、および境界線の色を制御するには、BorderWidth、BorderStyle、BorderColor の各プロパティそれぞれ設定しますWeb サーバー コントロールサイズ指定するには、Height プロパティWidth プロパティ使用します

コントロール動作は、特定のプロパティ設定して指定できますコントロールを有効または無効にするには、Enabled プロパティ設定しますタブ オーダーコントロール位置制御するには、TabIndex プロパティ設定しますコントロールツールヒント指定するには、ToolTip プロパティ設定します

メモメモ

このクラス定義されるプロパティ一部しかサポートしないコントロールありますプロパティサポートされかどうかについては、特定のコントロールに関するドキュメント参照してください

メモメモ

このクラスプロパティ中にはブラウザによって表示方法異なプロパティあります。まったく表示されないプロパティもあれば、表示には影響与えないプロパティあります。HttpBrowserCapabilities オブジェクトの TagWriter プロパティによって、Web サーバー コントロールでの表示方法決定しますHTML 4.0サポートするブラウザ場合TagWriter プロパティ通常の HttpBrowserCapabilities オブジェクト示し、ほとんどのプロパティHTML 4.0 スタイル属性使用して表示されます。HTML 4.0サポートすることが認識されないブラウザは、Html32TextWriter オブジェクト使用します。これによって、スタイル属性は、関連HTML 3.2 タグ属性自動的に変換されます。ForeColor プロパティ使用した場合などに、スタイル属性が、<font> タグなどの追加タグ変換される場合ありますまた、マップ実行されない場合ありますプロパティ各種ブラウザ表示する方法については、特定のプロパティに関するドキュメント参照してください

WebControlインスタンス初期プロパティ値の一覧については、WebControl コンストラクタトピック参照してください

使用例使用例
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls

Namespace ControlTest
   
   ' Renders the following HTML: 
   ' <span onclick="alert('Hello');" style="color:Red;">Custom
 Contents</span>
   Public Class MyWebControl
      Inherits WebControl
      
      
      Public Sub New()
         MyBase.New(HtmlTextWriterTag.Span)
      End Sub 'New      
      
      <System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand,
 Name:="FullTrust")> _
      Protected Overrides Sub
 AddAttributesToRender(writer As HtmlTextWriter)
         
         writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "alert('Hello');")
         writer.AddStyleAttribute(HtmlTextWriterStyle.Color, "Red")
         MyBase.AddAttributesToRender(writer)

      End Sub 'AddAttributesToRender
       

      <System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand,
 Name:="FullTrust")> _
      Protected Overrides Sub
 RenderContents(writer As HtmlTextWriter)
         writer.Write("Custom Contents")
         MyBase.RenderContents(writer)
      End Sub 'RenderContents

   End Class 'MyWebControl

End Namespace 'ControlTest

namespace ControlTest 
{
   using System;
   using System.Web.UI;
   using System.Web.UI.WebControls;

   // Renders the following HTML: 
   // <span onclick="alert('Hello');" style="color:Red;">Custom
 Contents</span>

   public class MyWebControl: WebControl {

      public MyWebControl() : base(HtmlTextWriterTag.Span)
 
      { }

      [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand,
 Name="FullTrust")] 
      protected override void AddAttributesToRender(HtmlTextWriter
 writer) 
      {

         writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "alert('Hello');");
         writer.AddStyleAttribute(HtmlTextWriterStyle.Color, "Red");
         base.AddAttributesToRender(writer);

      }

      [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand,
 Name="FullTrust")] 
      protected override void RenderContents(HtmlTextWriter
 writer) 
      {
         writer.Write("Custom Contents");
         base.RenderContents(writer);
      }
   }
}

package ControlTest; 
import System.*;
import System.Web.UI.*;
import System.Web.UI.WebControls.*;

// Renders the following HTML: 
// <span onclick="alert('Hello');" style="color:Red;">Custom
 Contents</span>
public class MyWebControl extends WebControl
{
    public MyWebControl()
    {
         super(HtmlTextWriterTag.Span);
    } //MyWebControl

    protected void AddAttributesToRender(HtmlTextWriter
 writer)
    {
        writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "alert('Hello');");
        writer.AddStyleAttribute(HtmlTextWriterStyle.Color, "Red");
        super.AddAttributesToRender(writer);
    } //AddAttributesToRender

    /** @attribute System.Security.Permissions.PermissionSet(System.Security.
        Permissions.SecurityAction.Demand, Name = "FullTrust")
     */
    protected void RenderContents(HtmlTextWriter
 writer)
    {
        writer.Write("Custom Contents");
        super.RenderContents(writer);
    } //RenderContents
} //MyWebControl
.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
   System.Web.UI.Control
    System.Web.UI.WebControls.WebControl
       派生クラス
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

「WebControl クラス」の関連用語

WebControl クラスのお隣キーワード
検索ランキング

   

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



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

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

©2024 GRAS Group, Inc.RSS