LoginStatusDesigner.GetDesignTimeHtml 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取用于在设计时呈现关联控件的标记。
public:
override System::String ^ GetDesignTimeHtml();
public override string GetDesignTimeHtml ();
override this.GetDesignTimeHtml : unit -> string
Public Overrides Function GetDesignTimeHtml () As String
返回
一个字符串,其中包含用于在设计时呈现 LoginStatus 的标记。
示例
下面的代码示例演示如何重写 GetDesignTimeHtml 从 LoginStatusDesigner 类继承的类中的 方法,以更改在设计时派生自 类的 LoginStatus 控件的外观。 如果 BorderStyle 控件的 属性为 NotSet 或 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.
MyLoginStatus myLoginStatusCtl = (MyLoginStatus)ViewControl;
string markup = null;
// Check if the border style should be changed.
if (myLoginStatusCtl.BorderStyle == BorderStyle.NotSet ||
myLoginStatusCtl.BorderStyle == BorderStyle.None)
{
BorderStyle oldBorderStyle = myLoginStatusCtl.BorderStyle;
Color oldBorderColor = myLoginStatusCtl.BorderColor;
// Set the design time properties and catch any exceptions.
try
{
myLoginStatusCtl.BorderStyle = BorderStyle.Dashed;
myLoginStatusCtl.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 myLoginStatusCtl As MyLoginStatus = _
CType(ViewControl, MyLoginStatus)
Dim markup As String = Nothing
' Check if the border style should be changed.
If (myLoginStatusCtl.BorderStyle = BorderStyle.NotSet Or _
myLoginStatusCtl.BorderStyle = BorderStyle.None) Then
Dim oldBorderStyle As BorderStyle = myLoginStatusCtl.BorderStyle
Dim oldBorderColor As Color = myLoginStatusCtl.BorderColor
' Set the design time properties and catch any exceptions.
Try
myLoginStatusCtl.BorderStyle = BorderStyle.Dashed
myLoginStatusCtl.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
注解
LogoutText如果 或 LoginText 属性 (,具体取决于用户是登录) ,是 null
、空字符串 (“”) ,还是单个空格 (“) ”,则GetDesignTimeHtml方法会根据需要将 或 LoginText 属性设置为LogoutTextID属性,将其括在方括号 (“[ ]”) 。 然后,无论 或 的设置LoginText如何,方法都会GetDesignTimeHtml调用GetDesignTimeHtml基方法,以便为控件的设计时呈现LoginStatus生成LogoutText标记。
继承者说明
如果重写 GetDesignTimeHtml() 方法,请务必调用 GetDesignTimeHtml() 基方法,因为它最终会通过多个重写级别调用 LoginStatus 控件或控件的副本来生成标记。