Share via


WebPartMobileExpandCollapseScriptManager.Render method

NOTE: This API is now obsolete.

Renders the ECMAScript code that implements expanding and collapsing a Web Part on a mobile page.

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

Syntax

'Declaration
<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 _
)
'Usage
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
)

Parameters

Remarks

Notes to callers

Calling code must verify that the current browser supports ECMAScript 1.x.x and CSS before it calls this method.

Notes to inheritors

If you override this method, your code must verify that the page is a WebPartMobilePage.

Examples

The following is an example of an override of this method.

 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

See also

Reference

WebPartMobileExpandCollapseScriptManager class

WebPartMobileExpandCollapseScriptManager members

Microsoft.SharePoint.WebPartPages namespace