WebPartMobileExpandCollapseScriptManager.Render Method
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)
Available in Sandboxed Solutions: No
Syntax
'Declaration
Protected Overrides Sub Render ( _
writer As HtmlTextWriter _
)
'Usage
Dim writer As HtmlTextWriter
Me.Render(writer)
protected override void Render(
HtmlTextWriter writer
)
Parameters
writer
Type: System.Web.UI.HtmlTextWriterThe object that actually writes the HTML script element.
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