AttributeCollection.Render メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > AttributeCollection.Render メソッドの意味・解説 

AttributeCollection.Render メソッド

指定した HtmlTextWriter 出力ストリーム属性コレクション書き込みますその後出力ストリームは、そのコレクション属すASP.NET サーバー コントロールにそのコレクション書き込みます

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

Public Sub Render ( _
    writer As HtmlTextWriter _
)
Dim instance As AttributeCollection
Dim writer As HtmlTextWriter

instance.Render(writer)
public void Render (
    HtmlTextWriter writer
)
public:
void Render (
    HtmlTextWriter^ writer
)
public void Render (
    HtmlTextWriter writer
)
public function Render (
    writer : HtmlTextWriter
)

パラメータ

writer

属性コレクション現在の出力ストリーム位置書き込む HtmlTextWriter オブジェクト

使用例使用例

このセクションには、2 つコード例含まれています。最初コード例では、WebControl クラスから継承してRender メソッドオーバーライドする AttribRender という名前のカスタム コントロール作成する方法示してます。2 番目のコード例では、カスタム コントロールASP.NET Web ページ使用する方法示してます。このコード例では、カスタム コントロールコード ファイルが、アプリケーションの App_Code フォルダにあることを前提にしています。

次のコード例では、基本クラスRender メソッド呼び出さずに、WebControl クラスRender メソッドオーバーライドする AttribRender という名前のカスタム コントロール作成する方法示してます。この場合AttribRenderRender メソッド呼び出します。

' Create a custom WebControl class, named AttribRender, that overrides
 
' the Render method to write two introductory strings. Then call the
' AttributeCollection.Render method, which allows the control to write
 the
' attribute values that are added to it when it is included in a page.
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Security.Permissions

' Create the namespace that contains the AttribRender and the
' page that accesses it.
Namespace AC_Render

 ' This is the custom WebControl class.
    <AspNetHostingPermission(SecurityAction.Demand, _
      Level:=AspNetHostingPermissionLevel.Minimal)> _
    Public Class AttribRender
        Inherits WebControl

        ' This is the overridden WebControl.Render method.
        Protected Overrides Sub
 Render(ByVal output As HtmlTextWriter)
            output.Write("<h2>An AttributeCollection.Render
 Method Example</h2>")
            output.Write("The attributes, and their values, added
 to the ctl1 control are <br><br>")
            ' This is the AttributeCollection.Render method call. When
 the
            ' page that contains this control is requested, the
            ' attributes that the page adds, and their values,
            ' are rendered to the page.
            Attributes.Render(output)
        End Sub 'Render
    End Class 'AttribRender

End Namespace 'AC_Render
/* Create a custom WebControl class, named AttribRender, that
 overrides 
   the Render method to write two introductory strings. Then call the
   AttributeCollection.Render method, which allows the control to write the
   attribute values that are added to it when it is included in
 a page.
*/
   
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Permissions;

// Create the namespace that contains the AttribRender and the
// page that accesses it.
namespace AC_Render
{
   // This is the custom WebControl class.
   [AspNetHostingPermission(SecurityAction.Demand, 
      Level=AspNetHostingPermissionLevel.Minimal)]
   public class AttribRender : WebControl
   {
      // This is the overridden WebControl.Render method.
      protected override void Render(HtmlTextWriter
 output)
      {
         output.Write("<h2>An AttributeCollection.Render Method Example</h2>");
         output.Write("The attributes, and their values, added to the ctl1 control
 are <br><br>");
         // This is the AttributeCollection.Render method call. When
 the
         // page that contains this control is requested, the
         // attributes that the page adds, and their values,
         // are rendered to the page.
         Attributes.Render(output);
      }
   }
}
/* Create a custom WebControl class, named AttribRender, that
 overrides 
   the Render method to write two introductory strings. Then call the
   AttributeCollection.Render method, which allows the control to write the
   attribute values that are added to it when it is included in
 a page.
   This sample can be used as a code-behind file for a.aspx file.
*/

// Create the package that contains the AttribRender and the
// page that accesses it.
package AC_Render; 

import System.*;
import System.Web.UI.*;
import System.Web.UI.WebControls.*;
   
// This is the custom WebControl class.
public class AttribRender extends WebControl
{
    // This is the overridden WebControl.Render method.
    protected void Render(HtmlTextWriter output)
    {
        output.Write("<h2>An AttributeCollection.Render Method Example</h2>");
        output.Write("The attributes, and their values, added to the ctl1 "
            + "control are <br><br>");

        // This is the AttributeCollection.Render method call. When
 the
        // page that contains this control is requested, the
        // attributes that the page adds, and their values,
        // are rendered to the page.
        get_Attributes().Render(output);
    } //Render
} //AttribRender   
   

次のコード例では、Web ページAttribRender カスタム コントロール使用する方法示してます。この例では、カスタム コントロールコード ファイルが、アプリケーションの App_Code フォルダにあることを前提にしています。

<%@ 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 Page_Load(ByVal
 sender As Object, ByVal
 e As System.EventArgs)

    Dim c As New AC_Render.AttribRender()
    c.Attributes.Add("Text", "Hello
 World!")
    c.Attributes.Add("Attribute1", "The
 value for Attribute1.")
    Place1.Controls.Add(c)

  End Sub
</script>

<html  >
<head runat="server">
    <title>AttributeCollection Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:PlaceHolder id="Place1" runat="server"></asp:PlaceHolder>
    </div>
    </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">

  protected void Page_Load(object sender, EventArgs
 e)
  {
    AC_Render.AttribRender c = new AC_Render.AttribRender();
    c.Attributes.Add("Text", "Hello World!");
    c.Attributes.Add("Attribute1", "The value for
 Attribute1.");
    Place1.Controls.Add(c);
    
  }
</script>

<html  >
<head runat="server">
    <title>AttributeCollection Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:PlaceHolder id="Place1" runat="server"></asp:PlaceHolder>
    </div>
    </form>
</body>
</html>
<%@ Page Language="VJ#" %>

<!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 Page_Load(Object sender, EventArgs
 e)
  {
    AC_Render.AttribRender c = new AC_Render.AttribRender();
    c.get_Attributes().Add("Text", "HelloWorld!");
    c.get_Attributes().Add("Attribute1", "The value for
 Attribute1.");
    get_Controls().Add(c);

  }
</script>

<html  >
<head id="Head1" runat="server">
    <title>AttributeCollection Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:PlaceHolder id="Place1" runat="server"></asp:PlaceHolder>
    </div>
    </form>
</body>
</html>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
AttributeCollection クラス
AttributeCollection メンバ
System.Web.UI 名前空間
Attributes
HtmlTextWriter
Attributes


このページでは「.NET Framework クラス ライブラリ リファレンス」からAttributeCollection.Render メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からAttributeCollection.Render メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からAttributeCollection.Render メソッド を検索

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

辞書ショートカット

すべての辞書の索引

AttributeCollection.Render メソッドのお隣キーワード
検索ランキング

   

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



AttributeCollection.Render メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS