HyperLinkDesigner クラスとは? わかりやすく解説

HyperLinkDesigner クラス

HyperLink Web サーバー コントロールを、ビジュアル デザイナで、デザイン時に使用できるようにします。

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

Public Class HyperLinkDesigner
    Inherits TextControlDesigner
Dim instance As HyperLinkDesigner
public class HyperLinkDesigner : TextControlDesigner
public ref class HyperLinkDesigner : public
 TextControlDesigner
public class HyperLinkDesigner extends TextControlDesigner
public class HyperLinkDesigner extends
 TextControlDesigner
解説解説
使用例使用例

このセクションには、2 つコード例含まれています。最初の例では、HyperLinkDesigner クラスからクラス派生してメソッドオーバーライドし、プロパティ値を提供する方法示します2 番目の例では、HyperLink コントロールかコントロール派生して、そのコントロール属性適用する方法示します

HyperLinkDesigner クラスから CustomHyperLinkDesigner クラス派生する方法次のコード例示しますText の元の値が空の文字列 ("") である場合GetDesignTimeHtml メソッドオーバーライドして Text プロパティ既定値提供します。これにより、関連付けられたコントロールデザイン時に表示されるようになります

' Derive the CustomHyperLinkDesigner from the HyperLinkDesigner.
Public Class CustomHyperLinkDesigner
    Inherits HyperLinkDesigner

    ' Override the GetDesignTimeHtml to set the CustomHyperLink Text
    ' property so that it displays at design time.
    Public Overrides Function
 GetDesignTimeHtml() As String

        Dim hype As CustomHyperLink = CType(Component,
 CustomHyperLink)
        Dim designTimeMarkup As String
 = Nothing

        ' Save the original Text and note if it is empty.
        Dim text As String
 = hype.Text
        Dim noText As Boolean
 = (text.Trim().Length = 0)

        Try
            ' If the Text is empty, supply a default value.
            If noText Then
                hype.Text = "Click here."
            End If

            ' Call the base method to generate the markup.
            designTimeMarkup = MyBase.GetDesignTimeHtml()

        Catch ex As Exception
            ' If an error occurs, generate the markup for an error message.
            designTimeMarkup = GetErrorDesignTimeHtml(ex)

        Finally
            ' Restore the original value of the Text, if necessary.
            If noText Then
                hype.Text = text
            End If
        End Try

        ' If the markup is empty, generate the markup for a placeholder.
        If ((designTimeMarkup = Nothing) Or
 _
            (designTimeMarkup.Length = 0)) Then
            designTimeMarkup = GetEmptyDesignTimeHtml()
        End If

        Return designTimeMarkup

    End Function ' GetDesignTimeHtml
End Class ' CustomHyperLinkDesigner
// Derive the CustomHyperLinkDesigner from the HyperLinkDesigner.
public class CustomHyperLinkDesigner : HyperLinkDesigner
{
    // Override the GetDesignTimeHtml to set the CustomHyperLink Text
 
    // property so that it displays at design time.
    public override string GetDesignTimeHtml()
    {
        CustomHyperLink hype = (CustomHyperLink)Component;
        string designTimeMarkup = null;

        // Save the original Text and note if it is empty.
        string text = hype.Text;
        bool noText = (text.Trim().Length == 0);

        try
        {
            // If the Text is empty, supply a default value.
            if (noText)
                hype.Text = "Click here.";

            // Call the base method to generate the markup.
            designTimeMarkup = base.GetDesignTimeHtml();
        }
        catch (Exception ex)
        {
            // If an error occurs, generate the markup for an error
 message.
            designTimeMarkup = GetErrorDesignTimeHtml(ex);
        }
        finally
        {
            // Restore the original value of the Text, if necessary.
            if (noText)
                hype.Text = text;
        }

        // If the markup is empty, generate the markup for a placeholder.
        if(designTimeMarkup == null || designTimeMarkup.Length
 == 0)
            designTimeMarkup = GetEmptyDesignTimeHtml();

        return designTimeMarkup;
    } // GetDesignTimeHtml
} // CustomHyperLinkDesigner

HyperLink コントロールかCustomHyperLink コントロール派生して、DesignerAttribute 属性CustomHyperLink コントロール適用して CustomHyperLinkDesigner関連付ける方法次のコード例示します

Imports System.Web
Imports System.ComponentModel
Imports System.Web.UI.WebControls
Imports System.Security.Permissions

Namespace Examples.VB.WebControls.Design

    ' The CustomHyperLink is a copy of the HyperLink.
    ' It uses the CustomHyperLinkDesigner for design-time support. 
    <AspNetHostingPermission(SecurityAction.Demand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    <Designer(GetType(Examples.VB.WebControls.Design. _
        CustomHyperLinkDesigner))> _
    Public Class CustomHyperLink
        Inherits HyperLink
    End Class ' CustomHyperLink
End Namespace ' Examples.VB.WebControls.Design
using System.Web;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Security.Permissions;

namespace Examples.CS.WebControls.Design
{
    // The CustomHyperLink is a copy of the HyperLink.
    // It uses the CustomHyperLinkDesigner for design-time support.
 
    [AspNetHostingPermission(SecurityAction.Demand, 
        Level = AspNetHostingPermissionLevel.Minimal)]
    [AspNetHostingPermission(SecurityAction.InheritanceDemand, 
        Level = AspNetHostingPermissionLevel.Minimal)]
    [Designer(typeof(Examples.CS.WebControls.Design.
        CustomHyperLinkDesigner))]
    public class CustomHyperLink : HyperLink
    {
    } // CustomHyperLink
} // Examples.CS.WebControls.Design
.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
   System.ComponentModel.Design.ComponentDesigner
     System.Web.UI.Design.HtmlControlDesigner
       System.Web.UI.Design.ControlDesigner
         System.Web.UI.Design.TextControlDesigner
          System.Web.UI.Design.WebControls.HyperLinkDesigner
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

「HyperLinkDesigner クラス」の関連用語

HyperLinkDesigner クラスのお隣キーワード
検索ランキング

   

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



HyperLinkDesigner クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS