Compartilhar via


WebPartPagesWebService.RenderWebPartForEdit Method

Returns an XML fragment that includes the Web Part property information and the rendering HTML.

Namespace:  [Webpartpages Web service]
Web service reference: http://Site/_vti_bin/Webpartpages.asmx

Syntax

'Declaration
<SoapDocumentMethodAttribute("https://microsoft.com/sharepoint/webpartpages/RenderWebPartForEdit", RequestNamespace := "https://microsoft.com/sharepoint/webpartpages",  _
    ResponseNamespace := "https://microsoft.com/sharepoint/webpartpages",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function RenderWebPartForEdit ( _
    webPartXml As String _
) As String
'Usage
Dim instance As WebPartPagesWebService
Dim webPartXml As String
Dim returnValue As String

returnValue = instance.RenderWebPartForEdit(webPartXml)
[SoapDocumentMethodAttribute("https://microsoft.com/sharepoint/webpartpages/RenderWebPartForEdit", RequestNamespace = "https://microsoft.com/sharepoint/webpartpages", 
    ResponseNamespace = "https://microsoft.com/sharepoint/webpartpages", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public string RenderWebPartForEdit(
    string webPartXml
)

Parameters

  • webPartXml
    Type: System.String

    A string containing the Web Part XML data.

Return Value

Type: System.String
A string that represents an XML fragment containing the Web Part property information and the rendering HTML.

Remarks

To access the WebPartPagesWebService service and its methods, set a Web reference to http://Virtual_Server_Name:Port_Number/_vti_adm/WebPartPages.asmx.

Examples

The following code example shows a locally defined RenderWebPartForEdit method that renders a Web Part by calling the RenderWebPartForEdit method of the Web Part Pages service through a proxy. It then displays the Web Part properties, the property values, and the rendered HTML. This code example and the proxy are part of a larger example provided for the Web Part Pages service.

Private Sub RenderWebPartForEdit()
    ' NOTE: The Web Service we are using is defined on MyServer/_vti_bin
    ' Declare and initialize a variable for the WebPartPages Web Service.
    Dim svc = New Microsoft.Samples.WebPartPagesSvcClient.WebpartpagesSvc.WebPartPagesWebService()
    ' Authenticate the current user by passing their default
    ' credentials to the Web Service from the system credential cache.
    svc.Credentials = System.Net.CredentialCache.DefaultCredentials
    ' Create Web Part XML inline 
    Dim webPartXml As String = "<?xml version=""1.0"" encoding=""utf-16""?>" + ControlChars.Lf + _
    "<WebPart xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" https://schemas.microsoft.com/WebPart/v2"">" + ControlChars.Lf + " " + _
    "<Title>Content Editor Web Part</Title>" + ControlChars.Lf + "  " + _
    "<FrameType>Default</FrameType>" + ControlChars.Lf + "  " + _
    "<Description>Use for formatted text, tables, and images.</Description>" + ControlChars.Lf + "  " + _
    "<IsIncluded>true</IsIncluded>" + ControlChars.Lf + "  " + _
    "<ZoneID>Header</ZoneID>" + ControlChars.Lf + "  " + _
    "<PartOrder>1</PartOrder>" + ControlChars.Lf + "  " + _
    "<FrameState>Normal</FrameState>" + ControlChars.Lf + "  " + _
    "<Height />" + ControlChars.Lf + "  " + _
    "<Width />" + ControlChars.Lf + "  " + _
    "<AllowRemove>true</AllowRemove>" + ControlChars.Lf + "  " + _
    "<AllowZoneChange>true</AllowZoneChange>" + ControlChars.Lf + "  " + _
    "<AllowMinimize>true</AllowMinimize>" + ControlChars.Lf + "  " + _
    "<IsVisible>true</IsVisible>" + ControlChars.Lf + "  " + _
    "<DetailLink />" + ControlChars.Lf + "  " + _
    "<HelpLink />" + ControlChars.Lf + "  " + _
    "<Dir>Default</Dir>" + ControlChars.Lf + "  " + _
    "<PartImageSmall />" + ControlChars.Lf + "  " + _
    "<MissingAssembly />" + ControlChars.Lf + "  " + _
    "<PartImageLarge>/_layouts/images/mscontl.gif</PartImageLarge>" + ControlChars.Lf + "  " + _
    "<IsIncludedFilter />" + ControlChars.Lf + "  " + _
    "<Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>" + ControlChars.Lf + "  " + _
"<TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>" + ControlChars.Lf + "  " + _
    "<ContentLink https://schemas.microsoft.com/WebPart/v2/ContentEditor"" />" + ControlChars.Lf + "  " + _
    "<Content https://schemas.microsoft.com/WebPart/v2/ContentEditor""><![CDATA[<P>Hello</P>]]></Content>" + ControlChars.Lf + "  " + _
    "<PartStorage https://schemas.microsoft.com/WebPart/v2/ContentEditor"" />" + ControlChars.Lf + " " + _
    "</WebPart>"
    Dim editPartXml As String = svc.RenderWebPartForEdit(webPartXml)
    Console.WriteLine("Result:" + ControlChars.Lf + "{0}" + ControlChars.Lf, editPartXml)
    Console.WriteLine("-----Hit enter-----")
    Console.ReadLine()
End Sub 'RenderWebPartForEdit
       
' result looks like: 
'     <Results>
'     <Result ID=\"0,RenderForEdit\" Code=\"0\">
'     <DesignerInfo>
'     <Properties>&lt;?xml version=\"1.0\" encoding=\"utf-16\"?&gt;\n&lt;WebPart xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
'         xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"https://schemas.microsoft.com/WebPart/v2\"&gt;\n  &lt;Title&gt;Announcements&lt;/Title&gt;\n  
'         &lt;FrameType&gt;Default&lt;/FrameType&gt;\n  &lt;Description&gt;Use the Announcements list to post messages on the home page 
'         of your site.&lt;/Description&gt;\n  
'         &lt;IsIncluded&gt;true&lt;/IsIncluded&gt;\n  &lt;ZoneID&gt;Footer&lt;/ZoneID&gt;\n  &
'         ...
'
'
 private void RenderWebPartForEdit ()
      {
        // NOTE: The Web Service we are using is defined on MyServer/_vti_bin
        // Declare and initialize a variable for the WebPartPages Web Service.
        WebpartpagesSvc.WebPartPagesWebService svc = new Microsoft.Samples.WebPartPagesSvcClient.WebpartpagesSvc.WebPartPagesWebService();
        // Authenticate the current user by passing their default
        // credentials to the Web Service from the system credential cache.
        svc.Credentials = System.Net.CredentialCache.DefaultCredentials;
        // create Web Part XML inline 
        string webPartXml = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\n" +
        "<WebPart xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"https://schemas.microsoft.com/WebPart/v2\">\n" +
        "<Title>Content Editor Web Part</Title>\n  " +
        "<FrameType>Default</FrameType>\n  " +
        "<Description>Use for formatted text, tables, and images.</Description>\n  " +
        "<IsIncluded>true</IsIncluded>\n  " +
        "<ZoneID>Header</ZoneID>\n  " +
        "<PartOrder>1</PartOrder>\n  " +
        "<FrameState>Normal</FrameState>\n  " +
        "<Height />\n  " +
        "<Width />\n  " +
        "<AllowRemove>true</AllowRemove>\n  " +
        "<AllowZoneChange>true</AllowZoneChange>\n  " +
        "<AllowMinimize>true</AllowMinimize>\n  " +
        "<IsVisible>true</IsVisible>\n  " +
        "<DetailLink />\n  " +
        "<HelpLink />\n  " +
        "<Dir>Default</Dir>\n  " +
        "<PartImageSmall />\n  " +
        "<MissingAssembly />\n  " +
        "<PartImageLarge>/_layouts/images/mscontl.gif</PartImageLarge>\n  " +
        "<IsIncludedFilter />\n  " +
        "<Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>\n  " +
        "<TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>\n  " +
        "<ContentLink xmlns=\"https://schemas.microsoft.com/WebPart/v2/ContentEditor\" />\n  " +
        "<Content xmlns=\"https://schemas.microsoft.com/WebPart/v2/ContentEditor\"><![CDATA[<P>Hello</P>]]></Content>\n  " +
        "<PartStorage xmlns=\"https://schemas.microsoft.com/WebPart/v2/ContentEditor\" />\n</WebPart>";
        string editPartXml = svc.RenderWebPartForEdit(webPartXml);
        Console.WriteLine("Result:\n{0}\n", editPartXml);
        Console.WriteLine("-----Hit enter-----");
        Console.ReadLine();
        /* result looks like: 
           <Results>
           <Result ID=\"0,RenderForEdit\" Code=\"0\">
           <DesignerInfo>
           <Properties>&lt;?xml version=\"1.0\" encoding=\"utf-16\"?&gt;\n&lt;WebPart xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"https://schemas.microsoft.com/WebPart/v2\"&gt;\n  &lt;Title&gt;Announcements&lt;/Title&gt;\n  
           &lt;FrameType&gt;Default&lt;/FrameType&gt;\n  &lt;Description&gt;Use the Announcements list to post messages on the home page of your site.&lt;/Description&gt;\n  
           &lt;IsIncluded&gt;true&lt;/IsIncluded&gt;\n  &lt;ZoneID&gt;Footer&lt;/ZoneID&gt;\n  &
           ...
        */   
      }

See Also

Reference

WebPartPagesWebService Class

WebPartPagesWebService Members

Webpartpages Web Service