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

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

Label.AddParsedSubObject メソッド

要素解析されたことをコントロール通知し、その要素Label コントロール追加します

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

Protected Overrides Sub
 AddParsedSubObject ( _
    obj As Object _
)
Dim obj As Object

Me.AddParsedSubObject(obj)
protected override void AddParsedSubObject
 (
    Object obj
)
protected:
virtual void AddParsedSubObject (
    Object^ obj
) override
protected void AddParsedSubObject (
    Object obj
)
protected override function AddParsedSubObject
 (
    obj : Object
)

パラメータ

obj

解析され要素を表すオブジェクト

解説解説
使用例使用例

カスタム Label サーバー コントロールAddParsedSubObject メソッドオーバーライドして、解析されオブジェクトLiteral場合は、常にテキスト プロパティ解析されオブジェクトテキスト プロパティ設定しそれ以外場合空の文字列設定する方法次のコード例示します

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls"
 Assembly="Samples.AspNet.VB"
 %>
<%@ Page Language="VB" AutoEventWireup="True"
 %>
<HTML>
    <HEAD>
        <title>Custom Label - AddParsedSubObject - VB.NET Example</title>
    </HEAD>
    <body>
        <form id="Form1" method="post"
 runat="server">
            <h3>Custom Label - AddParsedSubObject - VB.NET Example</h3>
            
            <aspSample:CustomLabelAddParsedSubObject id="Label1"
 runat="server" 
             ToolTip="Microsoft Corp.">Microsoft
 Corp.</aspSample:CustomLabelAddParsedSubObject>

        </form>
    </body>
</HTML>
<br /><span space="preserve">...</span><br
 />    <AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)>
 _
    Public NotInheritable Class
 CustomLabelAddParsedSubObject
        Inherits System.Web.UI.WebControls.Label

        Protected Overrides Sub
 AddParsedSubObject(ByVal obj As Object)

            ' If the server control contains any child controls.
            If Me.HasControls() Then

                ' Notify the base server control that an element, either
 XML or HTML, 
                ' was parsed, and adds the element to the server control's
 
                ' ControlCollection object.
                MyBase.AddParsedSubObject(obj)
                ' Else the server control doesn't contain any child
 controls.
            Else
                ' If the parsed element is a LiteralControl.
                If TypeOf obj Is
 System.Web.UI.LiteralControl Then

                    ' Set the server control's Text property to the
 parsed element's Text value.
                    Me.Text = CType(obj, System.Web.UI.LiteralControl).Text

                    ' Else the parsed element is not a LiteralControl.
                Else
                    ' If the server control has a value in the the Text
 property.
                    Dim currentText As String
 = Me.Text
                    If currentText.Length <> 0 Then

                        ' Set the server control's Text property to
 an empty string.
                        Me.Text = System.String.Empty

                        ' Notify the base server control that a new
 LiteralControl was parsed, 
                        ' and adds the element to the server control's
 ControlCollection object.
                        MyBase.AddParsedSubObject(New
 System.Web.UI.LiteralControl(currentText))
                    End If
                    MyBase.AddParsedSubObject(obj)
                End If
            End If
        End Sub
    End Class
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls"
 Assembly="Samples.AspNet.CS" %>
<%@ Page Language="C#" AutoEventWireup="True" %>
<HTML>
    <HEAD>
        <title>Custom Label - AddParsedSubObject - C# Example</title>
    </HEAD>
    <body>
        <form id="Form1" method="post" runat="server">
            <h3>Custom Label - AddParsedSubObject - C# Example</h3>
            
            <aspSample:CustomLabelAddParsedSubObject 
              id="Label1" runat="server" 
              ToolTip="Microsoft Corp.">Microsoft Corp.</aspSample:CustomLabelAddParsedSubObject>

        </form>
    </body>
</HTML>
<br /><span space="preserve">...</span><br />using
 System.Web;
using System.Security.Permissions;

namespace Samples.AspNet.CS.Controls
{
  [AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)]
  public sealed class CustomLabelAddParsedSubObject
 : System.Web.UI.WebControls.Label
  {
    protected override void AddParsedSubObject(object
 obj)
    {
      // If the server control contains any child controls.
      if (this.HasControls()) 
      {
        // Notify the base server control that an element, either XML
 or HTML, 
        // was parsed, and adds the element to the server control's
 
        // ControlCollection object.
        base.AddParsedSubObject(obj);
      }
        // Else the server control doesn't contain any child controls.
      else 
      {
        // If the parsed element is a LiteralControl.
        if (obj is System.Web.UI.LiteralControl) 
        {
          // Set the server control's Text property to the parsed element's
 Text value.
          this.Text = ((System.Web.UI.LiteralControl)obj).Text;
        }
          // Else the parsed element is not a LiteralControl.
        else 
        {
          // If the server control has a value in the the Text property.
          string currentText = this.Text;
          if (currentText.Length != 0) 
          {
            // Set the server control's Text property to an empty string.
            this.Text = System.String.Empty;

            // Notify the base server control that a new LiteralControl
 was parsed, 
            // and adds the element to the server control's ControlCollection
 object.
            base.AddParsedSubObject(new System.Web.UI.LiteralControl(currentText));
          }
          base.AddParsedSubObject(obj);
        }
      }
    }
  }
}
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls"
 Assembly="Samples.AspNet.JSL" %>
<%@ Page Language="VJ#" AutoEventWireup="True" %>
<HTML>
    <HEAD>
        <title>Custom Label - AddParsedSubObject - VJ# Example</title>
    </HEAD>
    <body>
        <form id="Form1" method="post" runat="server">
            <h3>Custom Label - AddParsedSubObject - VJ# Example</h3>
            
            <aspSample:CustomLabelAddParsedSubObject 
              id="Label1" runat="server" 
              ToolTip="Microsoft Corp.">Microsoft Corp.</aspSample:CustomLabelAddParsedSubObject>

        </form>
    </body>
</HTML>
<br /><span space="preserve">...</span><br />package
 Samples.AspNet.JSL.Controls; 

public class CustomLabelAddParsedSubObject
    extends System.Web.UI.WebControls.Label
{
    protected void AddParsedSubObject(Object
 obj)
    {
        // If the server control contains any child controls.
        if (this.HasControls()) {
            // Notify the base server control that an element, 
            // either XML or HTML, was parsed, and adds the element
 
            // to the server control's ControlCollection object.
            super.AddParsedSubObject(obj);
        }
        // Else the server control doesn't contain any child controls.
        else {
            // If the parsed element is a LiteralControl.
            if (obj instanceof System.Web.UI.LiteralControl) {
                // Set the server control's Text property to the parsed
 
                // element's Text value.
                this.set_Text(((System.Web.UI.LiteralControl)obj).get_Text());
            }
            // Else the parsed element is not a LiteralControl.
            else {
                // If the server control has a value in the the Text
 property.
                String currentText = this.get_Text();
                if (currentText.get_Length() != 0) {
                    // Set the server control's Text property to an
 empty 
                    // string.
                    this.set_Text("");
                    // Notify the base server control that a new 
                    // LiteralControl was parsed, and adds the element
 to 
                    // the server control's ControlCollection object.
                    super.AddParsedSubObject(new System.Web.UI.
                        LiteralControl(currentText));
                }
                super.AddParsedSubObject(obj);
            }
        }
    } //AddParsedSubObject
} //CustomLabelAddParsedSubObject
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2024 GRAS Group, Inc.RSS