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

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

HtmlImage.RenderAttributes メソッド

指定した HtmlTextWriter オブジェクトに、HtmlImage コントロールの属性をレンダリングします。

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

Protected Overrides Sub
 RenderAttributes ( _
    writer As HtmlTextWriter _
)
Dim writer As HtmlTextWriter

Me.RenderAttributes(writer)
protected override void RenderAttributes (
    HtmlTextWriter writer
)
protected:
virtual void RenderAttributes (
    HtmlTextWriter^ writer
) override
protected void RenderAttributes (
    HtmlTextWriter writer
)
protected override function RenderAttributes
 (
    writer : HtmlTextWriter
)

パラメータ

writer

クライアントに表示する出力ストリームを格納している HtmlTextWriter。

例外例外
解説解説

Src プロパティが正しくない形式の URL の場合、RenderAttributes メソッドは HttpException 例外をスローします。

RenderAttributes メソッドは、基本クラスの RenderAttributes メソッドをオーバーライドし、表示された HtmlImage コントロールの src 属性を書き込みます。

RenderAttributes メソッドは、主に、コントロール開発者が HtmlImage コントロールの機能を拡張する際に使用します。

使用例使用例

カスタム サーバー コントロールの RenderAttributes メソッドをオーバーライドして、ツールヒントとしてアクセスできる特定の代替テキストが常に HtmlImage コントロールと共に表示されるようにする方法を次のコード例に示します。

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls"
 Assembly="Samples.AspNet.VB"
 %>
<%@ Page Language="VB" AutoEventWireup="True"
 %>
<HTML>
  <HEAD>
    <title>Custom HtmlImage - RenderAttributes - Visual Basic Example</title>
  </HEAD>
  <body>
    <form id="Form1" method="post"
 runat="server">
      <h3>Custom HtmlImage - RenderAttributes - Visual Basic Example</h3>

      <aspSample:CustomHtmlImageRenderAttributes id="Img1"
        runat="server"
        border="0"
        src="image.jpg" />
    </form>
  </body>
</HTML>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls"
 Assembly="Samples.AspNet.CS" %>
<%@ Page Language="C#" AutoEventWireup="True" %>
<HTML>
  <HEAD>
    <title>Custom HtmlImage - RenderAttributes - C# Example</title>
  </HEAD>
  <body>
    <form id="Form1" method="post" runat="server">
      <h3>Custom HtmlImage - RenderAttributes - C# Example</h3>

      <aspSample:CustomHtmlImageRenderAttributes id="Img1"
        runat="server"
        border="0"
        src="image.jpg" />
    </form>
  </body>
</HTML>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls"
 Assembly="Samples.AspNet.JSL" %>
<%@ Page Language="VJ#" AutoEventWireup="True" %>
<HTML>
  <HEAD>
    <title>Custom HtmlImage - RenderAttributes - VJ# Example</title>
  </HEAD>
  <body>
    <form id="Form1" method="post" runat="server">
      <h3>Custom HtmlImage - RenderAttributes - VJ# Example</h3>

      <aspSample:CustomHtmlImageRenderAttributes id="Img1"
        runat="server"
        border="0"
        src="http://www.microsoft.com/homepage/gif/bnr-microsoft.gif"
 />
    </form>
  </body>
</HTML>
Imports System.Web
Imports System.Security.Permissions

Namespace Samples.AspNet.VB.Controls

    <AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)>
 _
    Public NotInheritable Class
 CustomHtmlImageRenderAttributes
        Inherits System.Web.UI.HtmlControls.HtmlImage

        Protected Overrides Sub
 RenderAttributes(ByVal writer As System.Web.UI.HtmlTextWriter)

            ' Call the base class's RenderAttributes method.
            MyBase.RenderAttributes(writer)

            ' Write out the HtmlImage control's alt tag.
            writer.Write(" alt=""Text
 from custom RenderAttributes method.""")
        End Sub
    End Class

End Namespace
using System.Web;
using System.Security.Permissions;

namespace Samples.AspNet.CS.Controls
{
    [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
    public sealed class CustomHtmlImageRenderAttributes
 : System.Web.UI.HtmlControls.HtmlImage
    {
        protected override void RenderAttributes(System.Web.UI.HtmlTextWriter
 writer)
        {
            // Call the base class's RenderAttributes method.
            base.RenderAttributes(writer);
            
            // Write out the HtmlImage control's alt tag.
            writer.Write(" alt=\"Text from custom RenderAttributes method.\"");
        }
    }
}
package Samples.AspNet.JSL.Controls;

public class CustomHtmlImageRenderAttributes
    extends System.Web.UI.HtmlControls.HtmlImage
{
    protected void RenderAttributes(System.Web.UI.HtmlTextWriter
 writer)
    {
        // Call the base's RenderAttributes method.
        super.RenderAttributes(writer);
        // Write out Title tag
        writer.Write(" alt=\"Text from custom RenderAttributes method.\"");
    } //RenderAttributes
} //CustomHtmlImageRenderAttributes
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

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

   

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



HtmlImage.RenderAttributes メソッドのページの著作権

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

©2026 GRAS Group, Inc.RSS