語言

LoginViewDesigner.GetEmptyDesignTimeHtml 方法

定義

取得標記,在設計時為相關控制項呈現佔位符,當目前範本尚未定義時。

protected:
 override System::String ^ GetEmptyDesignTimeHtml();
protected override string GetEmptyDesignTimeHtml();
override this.GetEmptyDesignTimeHtml : unit -> string
Protected Overrides Function GetEmptyDesignTimeHtml () As String

傳回

一個包含標記文字的字串,會渲染成設計表面上的佔位符。

範例

以下程式碼範例說明如何覆寫 GetEmptyDesignTimeHtml 從該類別繼承 LoginViewDesigner 的方法,以改變設計時從類別衍生出 LoginView 的控制項外觀。 範例產生一個佔位符的標記,該佔位符包含所有 RoleGroup 定義為相關控制項的物件名稱。

// Generate the design-time markup for the control 
// when the template is empty.
protected override string GetEmptyDesignTimeHtml()
{
    // Generate a design-time placeholder containing the names of all
    // the role groups.
    MyLoginView myLoginViewCtl = (MyLoginView)ViewControl;
    RoleGroupCollection roleGroups = myLoginViewCtl.RoleGroups;
    string roleNames = null;

    // If there are any role groups, form a string of their names.
    if (roleGroups.Count > 0)
    {
        roleNames = "Role Groups: <br />   " + 
            roleGroups[0].ToString();

        for( int rgX = 1; rgX < roleGroups.Count; rgX++ )
            roleNames += 
                "<br />   " + roleGroups[rgX].ToString();
    }
    return CreatePlaceHolderDesignTimeHtml( roleNames);
} // GetEmptyDesignTimeHtml
' Generate the design-time markup for the control 
' when the template is empty.
Protected Overrides Function GetEmptyDesignTimeHtml() As String

    ' Generate a design-time placeholder containing the names of all
    ' the role groups.
    Dim myLoginViewCtl As MyLoginView = CType(ViewControl, MyLoginView)
    Dim roleGroups As RoleGroupCollection = myLoginViewCtl.RoleGroups
    Dim RoleNames As String = Nothing
    Dim rgX As Integer

    ' If there are any role groups, form a string of their names.
    If roleGroups.Count > 0 Then

        roleNames = "Role Groups: <br />   " & _
            roleGroups(0).ToString()

        For rgX = 1 To roleGroups.Count - 1
            roleNames &= "<br />   " & _
                roleGroups(rgX).ToString()
        Next rgX
    End If

    Return CreatePlaceHolderDesignTimeHtml(roleNames)

End Function ' GetEmptyDesignTimeHtml

備註

此 GetEmptyDesignTimeHtml 方法首先格式化一個字串訊息,指定相關 LoginView 控制項目前範本的名稱,並指定該範本為空。 接著會 GetEmptyDesignTimeHtml 產生包含該訊息的佔位符標記。

適用於

另請參閱