ControlDesigner.GetDesignTimeHtml Metoda

Definice

Načte kód HTML, který se používá k reprezentaci ovládacího prvku v době návrhu.

Přetížení

Name Description
GetDesignTimeHtml(DesignerRegionCollection)

Načte kód HTML pro zobrazení ovládacího prvku a naplní kolekci oblastmi aktuálního návrháře ovládacích prvků.

GetDesignTimeHtml()

Načte kód HTML, který se používá k reprezentaci ovládacího prvku v době návrhu.

GetDesignTimeHtml(DesignerRegionCollection)

Načte kód HTML pro zobrazení ovládacího prvku a naplní kolekci oblastmi aktuálního návrháře ovládacích prvků.

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

Parametry

regions
DesignerRegionCollection

Kolekce oblastí návrháře ovládacích prvků pro přidružený ovládací prvek.

Návraty

Kód HTML v době návrhu přidruženého ovládacího prvku, včetně všech oblastí návrháře ovládacích prvků.

Příklady

Následující příklad kódu ukazuje, jak vytvořit kód HTML pomocí DesignerRegionCollection kolekce.

// Create the regions and design-time markup. Called by the designer host.
public override String GetDesignTimeHtml(DesignerRegionCollection regions) {
    // Create 3 regions: 2 clickable headers and an editable row
    regions.Add(new DesignerRegion(this, "Header0"));
    regions.Add(new DesignerRegion(this, "Header1"));

    // Create an editable region and add it to the regions
    EditableDesignerRegion editableRegion = 
        new EditableDesignerRegion(this, 
            "Content" + myControl.CurrentView, false);
    regions.Add(editableRegion);

    // Set the highlight for the selected region
    regions[myControl.CurrentView].Highlight = true;

    // Use the base class to render the markup
    return base.GetDesignTimeHtml();
}
' Create the regions and design-time markup. Called by the designer host.
Public Overrides Function GetDesignTimeHtml(ByVal regions As DesignerRegionCollection) As String
    ' Create 3 regions: 2 clickable headers and an editable row
    regions.Add(New DesignerRegion(Me, "Header0"))
    regions.Add(New DesignerRegion(Me, "Header1"))

    ' Create an editable region and add it to the regions
    Dim editableRegion As EditableDesignerRegion = _
        New EditableDesignerRegion(Me, _
            "Content" & myControl.CurrentView, False)
    regions.Add(editableRegion)

    ' Set the highlight for the selected region
    regions(myControl.CurrentView).Highlight = True

    ' Use the base class to render the markup
    Return MyBase.GetDesignTimeHtml()
End Function

Poznámky

Hostitel návrhu volá metodu GetDesignTimeHtml pro získání kódu HTML v době návrhu a aktuální seznam oblastí návrháře ovládacích prvků. Pomocí NávrhářRegionCollection může hostitel návrhu požádat o revize pro každou upravitelnou oblast návrháře ovládacího prvku.

Metoda GetDesignTimeHtml je poskytována pro odvozeného návrháře ovládacích prvků, jako GridViewDesigner je například třída, která musí zpracovat obsah oblasti před voláním GetDesignTimeHtml metody.

Viz také

Platí pro

GetDesignTimeHtml()

Načte kód HTML, který se používá k reprezentaci ovládacího prvku v době návrhu.

public:
 virtual System::String ^ GetDesignTimeHtml();
public virtual string GetDesignTimeHtml();
abstract member GetDesignTimeHtml : unit -> string
override this.GetDesignTimeHtml : unit -> string
Public Overridable Function GetDesignTimeHtml () As String

Návraty

Kód HTML, který se používá k reprezentaci ovládacího prvku v době návrhu.

Příklady

Následující příklad kódu ukazuje, jak přepsat metodu GetDesignTimeHtml v návrháři vlastních ovládacích prvků. Pokud je vlastnost Text přidruženého ovládacího prvku prázdná, GetDesignTimeHtml metoda volá metodu GetEmptyDesignTimeHtml . GetDesignTimeHtml V opačném případě metoda vytvoří a vykresluje hypertextový odkaz ovládacího prvku.

public override string GetDesignTimeHtml()
{
    if (simpleControl.Text.Length > 0)
    {
        string spec = "<a href='{0}.aspx'>{0}</a>";
        return String.Format(spec, simpleControl.Text);
    }
    else
    {
        return GetEmptyDesignTimeHtml();
    }
}
Public Overrides Function GetDesignTimeHtml() As String
   ' Component is the instance of the component or control that
   ' this designer object is associated with. This property is 
   ' inherited from System.ComponentModel.ComponentDesigner.
   simpleControl = CType(Component, Simple)
   
   If simpleControl.Text.Length > 0 Then
      Dim sw As New StringWriter()
      Dim tw As New HtmlTextWriter(sw)
      
      Dim placeholderLink As New HyperLink()
      
      ' Put simpleControl.Text into the link's Text.
      placeholderLink.Text = simpleControl.Text
      placeholderLink.NavigateUrl = simpleControl.Text
      placeholderLink.RenderControl(tw)
      
      Return sw.ToString()
   Else
      Return GetEmptyDesignTimeHtml()
   End If
End Function

Poznámky pro dědice

Pokud vytváříte vlastní ovládací prvek kontejneru, ujistěte se, že ovládací prvek a všechny podřízené ovládací prvky v době návrhu, bez ohledu na to, zda Visible je vlastnost nastavena nebo truefalse.

Viz také

Platí pro