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



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

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に収録されているすべての辞書からHtmlImage.RenderAttributes メソッドを検索する場合は、下記のリンクをクリックしてください。

- HtmlImage.RenderAttributes メソッドのページへのリンク