Sdílet prostřednictvím


HtmlTextArea.RenderAttributes(HtmlTextWriter) Metoda

Definice

Vykreslí HtmlTextArea atributy ovládacího prvku do zadaného HtmlTextWriter objektu.

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)

Parametry

writer
HtmlTextWriter

Tím HtmlTextWriter se zobrazí vykreslený obsah.

Příklady

Následující příklad kódu ukazuje, jak přepsat metodu RenderAttributes ve vlastním ovládacím prvku serveru, aby se pro ovládací prvek vždy zobrazoval konkrétní text nadpisu HtmlTextArea .

<%@ 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">
<script runat="server">
  
  void Page_Load(Object sender, EventArgs e)
  {
    HtmlTextArea1.Value = "Hello HTML Text Area World.";
  }
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head>
    <title>Custom HtmlTextArea RenderAttributes Example</title>
  </head>

  <body>
    <form id="Form1" 
          method="post" 
          runat="server">

      <h3>Custom HtmlTextArea - RenderAttributes - C# Example</h3>

      <aspSample:CustomHtmlTextAreaRenderAttributes 
        id="HtmlTextArea1" 
        name="HtmlTextArea1" 
        runat="server" 
        rows="4" 
        cols="50" />
        
    </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">
<script runat="server">

  Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    
    HtmlTextArea1.Value = "Hello HTML Text Area World."
    
  End Sub
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head>
    <title>Custom HtmlTextArea RenderAttributes Example</title>
  </head>

  <body>
    <form id="Form1" 
          method="post"
          runat="server">

      <h3>Custom HtmlTextArea RenderAttributes Example</h3>

      <aspSample:CustomHtmlTextAreaRenderAttributes 
        id="HtmlTextArea1" 
        name="HtmlTextArea1" 
        runat="server" 
        rows="4" 
        cols="50" />
        
    </form>
  </body>
</html>
using System.Web;
using System.Security.Permissions;

namespace Samples.AspNet.CS.Controls
{
    [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
    public sealed class CustomHtmlTextAreaRenderAttributes : System.Web.UI.HtmlControls.HtmlTextArea
    {
        protected override void RenderAttributes(System.Web.UI.HtmlTextWriter writer)
        {
            // Write out the Title attribute.
            writer.Write(" Title=\"Text from RenderAttributes.\"");
            
            // Call the base class's RenderAttributes method.
            base.RenderAttributes(writer);
        }
    }
}
Imports System.Web
Imports System.Security.Permissions

Namespace Samples.AspNet.VB.Controls
    <AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
    Public NotInheritable Class CustomHtmlTextAreaRenderAttributes
        Inherits System.Web.UI.HtmlControls.HtmlTextArea

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

            ' Write out the Title attribute.
            writer.Write(" Title=""Text from RenderAttributes.""")

            ' Call the base class's RenderAttributes method.
            MyBase.RenderAttributes(writer)
        End Sub
    End Class
End Namespace

Poznámky

Metoda RenderAttributes vykreslí name atribut HtmlTextArea ovládacího prvku přímo, aby se zajistilo, že má stejnou hodnotu jako Control.UniqueID vlastnost. Po vykreslení atributu RenderAttributes metoda volá metodu základní třídy RenderAttributes .

Metoda RenderAttributes se používá primárně ovládacími vývojáři, kteří rozšiřují funkce HtmlTextArea ovládacího prvku.

Platí pro

Viz také