LoginDesigner.GetDesignTimeHtml(DesignerRegionCollection) Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Recebe a marcação que é usada para renderizar o controlo associado no momento do design e preenche uma coleção de regiões designer.
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
Parâmetros
- regions
- DesignerRegionCollection
A DesignerRegionCollection à qual são adicionadas definições das regiões selecionáveis e clicáveis na vista de design time do controlo.
Devoluções
Uma string contendo a marcação usada para renderizar o Login momento do design.
Exemplos
O exemplo de código seguinte mostra como substituir o GetDesignTimeHtml método numa classe herdada LoginDesigner da classe para alterar a aparência de um controlo derivado do Login controlo no momento do projeto. O exemplo desenha uma borda azul tracejada em torno do controlo para tornar a sua extensão mais visível, se a BorderStyle propriedade do controlo for o NotSet valor ou 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
Observações
O GetDesignTimeHtml método cria um EditableDesignerRegion objeto para a LayoutTemplate propriedade do controlo associado Login e adiciona-o ao DesignerRegionCollection objeto referenciado pelo regions parâmetro. O GetDesignTimeHtml método utiliza o GetDesignTimeHtml método base para gerar a marcação para a renderização em tempo de design do Login controlo.
Notas para Herdeiros
Se sobrescreveres o GetDesignTimeHtml(DesignerRegionCollection) método, certifica-te de chamar o GetDesignTimeHtml() método base porque, eventualmente, através de vários níveis de sobrescritura, chama o Login controlo ou uma cópia do controlo para gerar a marcação.