Bagikan melalui


LoginDesigner.GetDesignTimeHtml(DesignerRegionCollection) Metode

Definisi

Mendapatkan markup yang digunakan untuk merender kontrol terkait pada waktu desain dan mengisi kumpulan wilayah desainer.

public:
 override System::String ^ GetDesignTimeHtml(System::Web::UI::Design::DesignerRegionCollection ^ regions);
public override string GetDesignTimeHtml (System.Web.UI.Design.DesignerRegionCollection regions);
override this.GetDesignTimeHtml : System.Web.UI.Design.DesignerRegionCollection -> string
Public Overrides Function GetDesignTimeHtml (regions As DesignerRegionCollection) As String

Parameter

regions
DesignerRegionCollection

DesignerRegionCollection definisi wilayah yang dapat dipilih dan dapat diklik dalam tampilan waktu desain kontrol ditambahkan.

Mengembalikan

String yang berisi markup yang digunakan untuk merender pada Login waktu desain.

Contoh

Contoh kode berikut menunjukkan cara mengambil GetDesignTimeHtml alih metode di kelas yang diwarisi dari LoginDesigner kelas untuk mengubah tampilan kontrol yang berasal dari Login kontrol pada waktu desain. Contoh menggambar batas biru putus-putus di sekitar kontrol untuk membuat jangkauannya lebih terlihat, jika BorderStyle properti kontrol adalah NotSet nilai atau None .

// Generate the design-time markup.
public override string GetDesignTimeHtml()
{
    // Make the control more visible in the designer.  If the border 
    // style is None or NotSet, change the border to a blue dashed line. 
    MyLogin myLoginCtl = (MyLogin)ViewControl;
    string markup = null;

    // Check if the border style should be changed.
    if (myLoginCtl.BorderStyle == BorderStyle.NotSet ||
        myLoginCtl.BorderStyle == BorderStyle.None)
    {
        BorderStyle oldBorderStyle = myLoginCtl.BorderStyle;
        Color oldBorderColor = myLoginCtl.BorderColor;

        // Set the design time properties and catch any exceptions.
        try
        {
            myLoginCtl.BorderStyle = BorderStyle.Dashed;
            myLoginCtl.BorderColor = Color.Blue;

            // Call the base method to generate the markup.
            markup = base.GetDesignTimeHtml();
        }
        catch (Exception ex)
        {
            markup = GetErrorDesignTimeHtml(ex);
        }
        finally
        {
            // It is not necessary to restore the border properties 
            // to their original values because the ViewControl 
            // was used to reference the associated control and the 
            // UsePreviewControl was not overridden.  

            // myLoginCtl.BorderStyle = oldBorderStyle;
            // myLoginCtl.BorderColor = oldBorderColor;
        }
    }
    else
    {
        // Call the base method to generate the markup.
        markup = base.GetDesignTimeHtml();
    }

    return markup;
} // GetDesignTimeHtml
' Generate the design-time markup.
Public Overrides Function GetDesignTimeHtml() As String

    ' Make the control more visible in the designer.  If the border 
    ' style is None or NotSet, change the border to a blue dashed line. 
    Dim myLoginCtl As MyLogin = CType(ViewControl, MyLogin)
    Dim markup As String = Nothing

    ' Check if the border style should be changed.
    If (myLoginCtl.BorderStyle = BorderStyle.NotSet Or _
        myLoginCtl.BorderStyle = BorderStyle.None) Then

        Dim oldBorderStyle As BorderStyle = myLoginCtl.BorderStyle
        Dim oldBorderColor As Color = myLoginCtl.BorderColor

        ' Set the design time properties and catch any exceptions.
        Try
            myLoginCtl.BorderStyle = BorderStyle.Dashed
            myLoginCtl.BorderColor = Color.Blue

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

        Catch ex As Exception
            markup = GetErrorDesignTimeHtml(ex)

        Finally
            ' It is not necessary to restore the border properties 
            ' to their original values because the ViewControl 
            ' was used to reference the associated control and the 
            ' UsePreviewControl was not overridden.  

            ' myLoginCtl.BorderStyle = oldBorderStyle
            ' myLoginCtl.BorderColor = oldBorderColor
        End Try

    Else
        ' Call the base method to generate the markup.
        markup = MyBase.GetDesignTimeHtml()
    End If

    Return markup

End Function ' GetDesignTimeHtml

Keterangan

Metode GetDesignTimeHtml ini membuat EditableDesignerRegion objek untuk LayoutTemplate properti kontrol terkait Login dan menambahkannya ke DesignerRegionCollection objek yang dirujuk oleh regions parameter . Metode ini GetDesignTimeHtml menggunakan GetDesignTimeHtml metode dasar untuk menghasilkan markup untuk penyajian Login waktu desain kontrol.

Catatan Bagi Inheritor

Jika Anda mengambil GetDesignTimeHtml(DesignerRegionCollection) alih metode , pastikan untuk memanggil GetDesignTimeHtml() metode dasar karena pada akhirnya, melalui beberapa tingkat penimpaan, panggilan pada Login kontrol atau salinan kontrol untuk menghasilkan markup.

Berlaku untuk

Lihat juga