HtmlAnchor.RenderAttributes(HtmlTextWriter) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
HtmlAnchor 컨트롤의 특성을 지정된 HtmlTextWriter 개체에 렌더링합니다.
protected:
override void RenderAttributes(System::Web::UI::HtmlTextWriter ^ writer);
protected override void RenderAttributes (System.Web.UI.HtmlTextWriter writer);
override this.RenderAttributes : System.Web.UI.HtmlTextWriter -> unit
Protected Overrides Sub RenderAttributes (writer As HtmlTextWriter)
매개 변수
- writer
- HtmlTextWriter
클라이언트에서 렌더링할 출력 스트림이 포함된 HtmlTextWriter입니다.
예외
HRef에 잘못된 URL이 포함된 경우
예제
다음 코드 예제에서는 도구 설명으로 액세스할 수 있는 특정 제목 텍스트 컨트롤에 대해 항상 표시 되도록 사용자 지정 서버 컨트롤에서 메서드를 재정 RenderAttributes 의 HtmlAnchor 하는 방법을 보여 줍니다.
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>
<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Custom HtmlAnchor - RenderAttributes - C# Example</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
Top of Page
<<aspSample:CustomHtmlAnchorRenderAttributes
id="HtmlAnchor1"
runat="server"
name="HtmlAnchor1">HtmlAnchor1</aspSample:CustomHtmlAnchorRenderAttributes>>
<h3>Custom HtmlAnchor - RenderAttributes - C# Example</h3>
<p>Place the mouse pointer over the HtmlAnchor1 tag (above). A Title attribute was added from within the RenderAttributes override method.</p>
<p>Jump to <a href="#HtmlAnchor2">HtmlAnchor2</a> below.</p>
<p> </p><p> </p><p> </p><p> </p>
<p> </p><p> </p><p> </p><p> </p>
<p> </p><p> </p><p> </p><p> </p>
<p> </p><p> </p><p> </p><p> </p>
<p> </p><p> </p><p> </p><p> </p>
<p> </p><p> </p><p> </p><p> </p>
<p> </p><p> </p><p> </p><p> </p>
<p> </p><p> </p><p> </p><p> </p>
<p> </p><p> </p><p> </p><p> </p>
<p> </p><p> </p><p> </p><p> </p>
<p>Jump to <a href="#HtmlAnchor1">HtmlAnchor1</a> above.</p>
<p> </p>Bottom of Page
<<aspSample:CustomHtmlAnchorRenderAttributes
id="HtmlAnchor2"
runat="server"
name="HtmlAnchor2">HtmlAnchor2</aspSample:CustomHtmlAnchorRenderAttributes>>
</form>
</body>
</html>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Custom HtmlAnchor - RenderAttributes - Visual Basic Example</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
Top of Page
<<aspSample:CustomHtmlAnchorRenderAttributes
id="HtmlAnchor1"
runat="server"
name="HtmlAnchor1">HtmlAnchor1</aspSample:CustomHtmlAnchorRenderAttributes>>
<h3>Custom HtmlAnchor - RenderAttributes - Visual Basic Example</h3>
<p>Place the mouse pointer over the HtmlAnchor1 tag (above). A Title attribute was added from within the RenderAttributes override method.</p>
<p>Jump to <a href="#HtmlAnchor2">HtmlAnchor2</a> below.</p>
<p> </p><p> </p><p> </p><p> </p>
<p> </p><p> </p><p> </p><p> </p>
<p> </p><p> </p><p> </p><p> </p>
<p> </p><p> </p><p> </p><p> </p>
<p> </p><p> </p><p> </p><p> </p>
<p> </p><p> </p><p> </p><p> </p>
<p> </p><p> </p><p> </p><p> </p>
<p> </p><p> </p><p> </p><p> </p>
<p> </p><p> </p><p> </p><p> </p>
<p> </p><p> </p><p> </p><p> </p>
<p>Jump to <a href="#HtmlAnchor1">HtmlAnchor1</a> above.</p>
<p> </p>Bottom of Page
<<aspSample:CustomHtmlAnchorRenderAttributes
id="HtmlAnchor2"
runat="server"
name="HtmlAnchor2">HtmlAnchor2</aspSample:CustomHtmlAnchorRenderAttributes>>
</form>
</body>
</html>
using System.Web;
using System.Security.Permissions;
namespace Samples.AspNet.CS.Controls
{
[AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class CustomHtmlAnchorRenderAttributes : System.Web.UI.HtmlControls.HtmlAnchor
{
protected override void RenderAttributes(System.Web.UI.HtmlTextWriter writer)
{
// Call the base class's RenderAttributes method.
base.RenderAttributes(writer);
// Write out the HtmlAnchor control's Title tag.
writer.Write(" Title=\"Text from RenderAttributes.\"");
}
}
}
Imports System.Web
Imports System.Security.Permissions
Namespace Samples.AspNet.VB.Controls
<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class CustomHtmlAnchorRenderAttributes
Inherits System.Web.UI.HtmlControls.HtmlAnchor
Protected Overrides Sub RenderAttributes(ByVal writer As System.Web.UI.HtmlTextWriter)
' Call the base class's RenderAttributes method.
MyBase.RenderAttributes(writer)
' Write out the HtmlAnchor control's Title tag.
writer.Write(" Title=""Text from RenderAttributes.""")
End Sub
End Class
End Namespace
설명
경우의 값을 HRef 속성이 잘못 된 URL을 RenderAttributes 메서드가 throw는 HttpException 예외.