共用方式為


WebPartMobileExpandCollapseScriptManager.Render method

NOTE: This API is now obsolete.

呈現實作展開和摺疊在行動頁面上的網頁組件的採用程式碼。

Namespace:  Microsoft.SharePoint.WebPartPages
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'宣告
<ObsoleteAttribute("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see https://go.microsoft.com/fwlink/?LinkId=157231.")> _
Protected Overrides Sub Render ( _
    writer As HtmlTextWriter _
)
'用途
Dim writer As HtmlTextWriter

Me.Render(writer)
[ObsoleteAttribute("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see https://go.microsoft.com/fwlink/?LinkId=157231.")]
protected override void Render(
    HtmlTextWriter writer
)

參數

備註

Notes to callers

呼叫程式碼必須確認目前的瀏覽器支援採用 1.x.x 和 CSS 之前,它會呼叫這個方法。

Notes to inheritors

如果您覆寫這個方法,您的程式碼必須確認資料頁就是WebPartMobilePage

Examples

下列是覆寫這個方法的範例。

 protected override void Render(HtmlTextWriter writer)
{
    WebPartMobilePage mobilePage = this.MobilePage as WebPartMobilePage;
    if (null == mobilePage)
    {
        return;
    }

    if (mobilePage.SupportsExpandCollapse)
    {
        StringBuilder scriptString = new StringBuilder();
    
        scriptString.AppendLine();
        scriptString.AppendLine("<script type=\"text/javascript\">");
        scriptString.AppendLine("// <![CDATA[");
        scriptString.Append("function ");
        scriptString.Append("MyExpandCollapseToggle");
        scriptString.AppendLine("(container){");
        scriptString.AppendLine("  if (container.style.display != 'none'){");
        scriptString.AppendLine("    container.style.display = 'none';}");
        scriptString.AppendLine("  else {");
        scriptString.AppendLine("    container.style.display = '';}");
        scriptString.AppendLine("}");
        scriptString.AppendLine("// ]]>");
        scriptString.AppendLine("</script>");
        scriptString.AppendLine();

        writer.Write(scriptString.ToString());
    }
}
Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
    Dim mobilePage As WebPartMobilePage = TryCast(Me.MobilePage, WebPartMobilePage)
    If Nothing Is mobilePage Then
        Return
    End If

    If mobilePage.SupportsExpandCollapse Then
        Dim scriptString As New StringBuilder()

        scriptString.AppendLine()
        scriptString.AppendLine("<script type=""text/javascript"">")
        scriptString.AppendLine("// <![CDATA[")
        scriptString.Append("function ")
        scriptString.Append("MyExpandCollapseToggle")
        scriptString.AppendLine("(container){")
        scriptString.AppendLine("  if (container.style.display != 'none'){")
        scriptString.AppendLine("    container.style.display = 'none';}")
        scriptString.AppendLine("  else {")
        scriptString.AppendLine("    container.style.display = '';}")
        scriptString.AppendLine("}")
        scriptString.AppendLine("// ]]>")
        scriptString.AppendLine("</script>")
        scriptString.AppendLine()

        writer.Write(scriptString.ToString())
    End If
 End Sub

請參閱

參照

WebPartMobileExpandCollapseScriptManager class

WebPartMobileExpandCollapseScriptManager members

Microsoft.SharePoint.WebPartPages namespace