Views.UpdateViewHtml Method
Updates the specified view with the supplied properties and values, including the display properties of Introduction to Collaborative Application Markup Language (CAML) and HTML.
Namespace: [Views Web service]
Web service reference: http://Site/_vti_bin/Views.asmx
Syntax
'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/UpdateViewHtml", RequestNamespace := "https://schemas.microsoft.com/sharepoint/soap/", _
ResponseNamespace := "https://schemas.microsoft.com/sharepoint/soap/", _
Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function UpdateViewHtml ( _
listName As String, _
viewName As String, _
viewProperties As XmlNode, _
toolbar As XmlNode, _
viewHeader As XmlNode, _
viewBody As XmlNode, _
viewFooter As XmlNode, _
viewEmpty As XmlNode, _
rowLimitExceeded As XmlNode, _
query As XmlNode, _
viewFields As XmlNode, _
aggregations As XmlNode, _
formats As XmlNode, _
rowLimit As XmlNode _
) As XmlNode
'Usage
Dim instance As Views
Dim listName As String
Dim viewName As String
Dim viewProperties As XmlNode
Dim toolbar As XmlNode
Dim viewHeader As XmlNode
Dim viewBody As XmlNode
Dim viewFooter As XmlNode
Dim viewEmpty As XmlNode
Dim rowLimitExceeded As XmlNode
Dim query As XmlNode
Dim viewFields As XmlNode
Dim aggregations As XmlNode
Dim formats As XmlNode
Dim rowLimit As XmlNode
Dim returnValue As XmlNode
returnValue = instance.UpdateViewHtml(listName, _
viewName, viewProperties, toolbar, _
viewHeader, viewBody, viewFooter, _
viewEmpty, rowLimitExceeded, query, _
viewFields, aggregations, formats, _
rowLimit)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/UpdateViewHtml", RequestNamespace = "https://schemas.microsoft.com/sharepoint/soap/",
ResponseNamespace = "https://schemas.microsoft.com/sharepoint/soap/",
Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public XmlNode UpdateViewHtml(
string listName,
string viewName,
XmlNode viewProperties,
XmlNode toolbar,
XmlNode viewHeader,
XmlNode viewBody,
XmlNode viewFooter,
XmlNode viewEmpty,
XmlNode rowLimitExceeded,
XmlNode query,
XmlNode viewFields,
XmlNode aggregations,
XmlNode formats,
XmlNode rowLimit
)
Parameters
listName
Type: System.StringA string that contains the internal name of the list.
viewName
Type: System.StringA string that contains the GUID for the view.
viewProperties
Type: System.Xml.XmlNodeAn XML fragment that contains all view-level properties as attributes, such as Editor, Hidden, ReadOnly, and Title.
toolbar
Type: System.Xml.XmlNodeA Toolbar element that sets the HTML used to render the toolbar in a view and that can be assigned to a System.Xml.XmlNode object, as in the following example:
<Toolbar Type="Standard"> <IfEqual> <Expr1> <GetVar Name="SearchString" /> </Expr1> <Expr2 /> <Then> ... </Toolbar>
viewHeader
Type: System.Xml.XmlNodeA ViewHeader element that sets the HTML used to render the header of a view and that can be assigned to a System.Xml.XmlNode object, as in the following example:
<ViewHeader> <HTML> <![CDATA[ <TABLE width="100%" cellspacing=0 cellpadding=0 border=0> ]]> </HTML> ... </ViewHeader>
viewBody
Type: System.Xml.XmlNodeA ViewBody element that sets the HTML used to render the body of a view and that can be assigned to a System.Xml.XmlNode object, as in the following example:
<ViewBody> <HTML> <![CDATA[ <TR>]]> </HTML> <Fields> <HTML> <![CDATA[ <TD Class=" ]]> </HTML> ... </ViewBody>
viewFooter
Type: System.Xml.XmlNodeA ViewFooter element that sets the HTML used to render the footer of a view and that can be assigned to a System.Xml.XmlNode object, as in the following example:
<ViewFooter> <HTML> <![CDATA[ </TABLE> ]]> </HTML> <IfEqual> ... </ViewFooter>
viewEmpty
Type: System.Xml.XmlNodeA ViewEmpty element that contains the HTML used to render the page if the query returns no items and that can be assigned to a System.Xml.XmlNode object, as in the following example:
<ViewEmpty> <HTML> <![CDATA[ <TABLE width="100%" cellspacing=0 cellpadding=0 border=0><tr><td> ]]> </HTML> ... </ViewEmpty>
rowLimitExceeded
Type: System.Xml.XmlNodeA RowLimitExceeded element that specifies alternate rendering for when the specified row limit is exceeded and that can be assigned to a System.Xml.XmlNode object, as in the following example:
<RowLimitExceeded> <HTML><![CDATA[ <table class="ms-summarycustombody" cellpadding=0 cellspacing=0 border=0 rules=rows> ... </td></tr></table> ]]> </HTML> </RowLimitExceeded>
query
Type: System.Xml.XmlNodeA Query element containing the query that determines which records are returned and in what order, and that can be assigned to a System.Xml.XmlNode object. The following example performs a query for cases in which the ID field is less than 3, and displays items in the order of their titles:
<Query> <Where> <Lt> <FieldRef Name="ID" /> <Value Type="Counter">3</Value> </Lt> </Where> <OrderBy> <FieldRef Name="Title" /> </OrderBy> </Query>
viewFields
Type: System.Xml.XmlNodeA ViewFields element that specifies which fields to return in the query and in what order, and that can be assigned to a System.Xml.XmlNode object, as in the following example:
<ViewFields> <FieldRef Name="ID" /> <FieldRef Name="Title" /> </ViewFields>
aggregations
Type: System.Xml.XmlNodeAn Aggregations element that specifies the fields to aggregate and that can be assigned to a System.Xml.XmlNode object, as in the following example:
<Aggregations Value="On"> <FieldRef Name="Title" Type="Count"> <FieldRef Name="Number" Type="Sum"> </Aggregations>
formats
Type: System.Xml.XmlNodeA Formats element that defines the grid formatting for columns and that can be assigned to a System.Xml.XmlNode object, as in the following example:
<Formats> <FormatDef Type="RowHeight" Value="67" /> <Format Name="Attachments"> <FormatDef Type="ColWidth" Value="75" /> </Format> <Format Name="LinkTitle"> <FormatDef Type="WrapText" Value="1" /> <FormatDef Type="ColWidth" Value="236" /> </Format> ... </Formats>
rowLimit
Type: System.Xml.XmlNodeA RowLimit element that specifies the number of items, or rows, to display on a page before paging begins and that can be assigned to a System.Xml.XmlNode object. The fragment can include the Paged attribute to specify that the view return list items in pages. The following example sets a limit of 100 items per page:
<RowLimit Paged="True">100</RowLimit>
Return Value
Type: System.Xml.XmlNode
A CAML fragment in the following form that contains the view schema and that can be assigned to a System.Xml.XmlNode object.
<View Name="{54992C89-4F9F-4B2E-8E5A-F55C1C70831B}" Type="HTML" DisplayName="MyView" Url="Lists/TestCustList/MyView.aspx" BaseViewID="1" xmlns="https://schemas.microsoft.com/sharepoint/soap/">
<ViewFields>
<FieldRef Name="Attachments" />
<FieldRef Name="LinkTitle" />
<FieldRef Name="ID" />
<FieldRef Name="Created" />
</ViewFields>
<Query>
...
</Query>
<ViewEmpty>
...
</ViewEmpty>
<GroupByHeader>
...
</GroupByHeader>
<GroupByFooter>
...
</GroupByFooter>
<ViewHeader>
...
</ViewHeader>
<ViewBody>
...
</ViewBody>
<ViewFooter>
...
</ViewFooter>
<PagedRowset>
...
</PagedRowset>
<PagedRecurrenceRowset>
...
</PagedRecurrenceRowset>
<RowLimit Paged="TRUE">100</RowLimit>
<ViewBidiHeader>
...
</ViewBidiHeader>
<Toolbar Type="Standard">
...
</Toolbar>
</View>
Remarks
To modify only the query and field definitions in a view, use the UpdateView method.
Examples
The following code example modifies the View Footer region in a view, adding text and a hyperlink to the Announcements list in the current site.
Dim viewService As New Web_Reference_Folder.Views()
viewService.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim xmlDoc = New System.Xml.XmlDocument()
Dim strViewEmpty As String = "<HTML><![CDATA[" + _
"<TABLE width="100%" cellspacing=0 cellpadding=0 border=0>" + _
"<tr><td>]]></HTML>" + _
"<HTML><![CDATA[" + _
"<TABLE ID=onetidDoclibViewTbl0 width="100%" Summary="]]>" + _
"</HTML><ListProperty Select="Title" HTMLEncode="TRUE" />" + _
"<HTML><![CDATA[" ]]></HTML>" + _
"<HTML><![CDATA[border=0 rules=rows><TR>]]>" + _
"</HTML><Fields><Switch><Expr>" + _
"<Property Select="Name" /></Expr><Case Value="Attachments">" + _
"<HTML><![CDATA[<TH class="ms-vh-icon">]]></HTML>" + _
"<Field /><HTML><![CDATA[</TH>]]></HTML>" + _
"</Case><Default><Switch><Expr>" + _
"<Property Select="HeaderImage" /></Expr><Case Value="">" + _
"<HTML><![CDATA[<TH class="ms-vh">]]></HTML>" + _
"<Field /><HTML><![CDATA[</TH>]]></HTML>" + _
"</Case><Default><HTML>" + _
"<![CDATA[<TH class="ms-vh-icon">]]></HTML><Field />" + _
"<HTML><![CDATA[</TH>]]></HTML></Default></Switch>" + _
"</Default></Switch></Fields>" + _
"<HTML><![CDATA[</TR>]]></HTML>" + _
"<HTML><![CDATA[</TABLE>]]></HTML>" + _
"<HTML><![CDATA[</td></tr>]]></HTML>" + _
"<HTML><![CDATA[<tr><td>]]></HTML>" + _
"<HTML><![CDATA[<TABLE ]]></HTML>" + _
"<HTML><![CDATA[ width=100% ]]></HTML>" + _
"<HTML><![CDATA[ border=0 rules=rows><TR>]]></HTML>" + _
"<IfEqual><Expr1>" + _
"<GetVar Name="SearchString" /></Expr1><Expr2 /><Then><HTML>" + _
"<![CDATA[<TD Class="ms-vb"> ]]></HTML>" + _
"<HTML>All work items in the "</HTML>" + _
"<ListProperty Select="Title" HTMLEncode="TRUE" />" + _
"<HTML>" list have been completed. See </HTML>" + _
"<HTML><![CDATA[<A HREF="]]></HTML>" + _
"<HttpVDir URLEncode="TRUE"/>" + _
"<HTML><![CDATA[/Lists/Announcements/AllItems.aspx">]]></HTML>" + _
"<HTML>Announcements</HTML><HTML><![CDATA[</A>]]></HTML>" + _
"<HTML> for details.</HTML>" + _
"<HTML><![CDATA[</TD>]]></HTML></Then>" + _
"<Else><HTML><![CDATA[<TD class="ms-vb"><B>]]></HTML>" + _
"<HTML>No records were found matching your query.</HTML>" + _
"<HTML><![CDATA[</B></TD>]]></HTML></Else></IfEqual>" + _
"<HTML><![CDATA[</TR></TABLE>]]></HTML>" + _
"<HTML><![CDATA[</td></tr></TABLE>]]></HTML>"
Dim ndViewEmpty As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "ViewEmpty", "")
ndViewEmpty.InnerXml = strViewEmpty
viewService.UpdateViewHtml("List_Name", "9781bd25-1f68-481f-81d3-1e4f3f9216dd", Nothing, Nothing, Nothing, Nothing, Nothing, _ ndViewEmpty, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)
Web_Reference_Folder.Views viewService = new Web_Reference_Folder.Views();
viewService.Credentials= System.Net.CredentialCache.DefaultCredentials;
XmlDocument xmlDoc = new System.Xml.XmlDocument();
string strViewEmpty = "<HTML><![CDATA[" +
"<TABLE width=\"100%\" cellspacing=0 cellpadding=0 border=0>" +
"<tr><td>]]></HTML><HTML><![CDATA[" +
"<TABLE ID=onetidDoclibViewTbl0 width=\"100%\" Summary=\"]]>" +
"</HTML><ListProperty Select=\"Title\" HTMLEncode=\"TRUE\" />" +
"<HTML><![CDATA[\" ]]></HTML>" +
"<HTML><![CDATA[border=0 rules=rows><TR>]]></HTML>" +
"<Fields><Switch><Expr>" +
"<Property Select=\"Name\" /></Expr><Case Value=\"Attachments\">" +
"<HTML><![CDATA[<TH class=\"ms-vh-icon\">]]></HTML>" +
"<Field /><HTML><![CDATA[</TH>]]></HTML>" +
"</Case><Default><Switch><Expr>" +
"<Property Select=\"HeaderImage\" /></Expr><Case Value=\"\">" +
"<HTML><![CDATA[<TH class=\"ms-vh\">]]></HTML>" +
"<Field /><HTML><![CDATA[</TH>]]></HTML>" +
"</Case><Default><HTML><![CDATA[" +
"<TH class=\"ms-vh-icon\">]]></HTML><Field />" +
"<HTML><![CDATA[</TH>]]></HTML>" +
"</Default></Switch></Default></Switch></Fields>" +
"<HTML><![CDATA[</TR>]]></HTML><HTML><![CDATA[</TABLE>]]></HTML>" +
"<HTML><![CDATA[</td></tr>]]></HTML>" +
"<HTML><![CDATA[<tr><td>]]></HTML>" +
"<HTML><![CDATA[<TABLE ]]></HTML>" +
"<HTML><![CDATA[ width=100% ]]></HTML>" +
"<HTML><![CDATA[ border=0 rules=rows><TR>]]></HTML>" +
"<IfEqual><Expr1>" +
"<GetVar Name=\"SearchString\" /></Expr1><Expr2 /><Then><HTML>" +
"<![CDATA[<TD Class=\"ms-vb\"> ]]></HTML>" +
"<HTML>All work items in the \"</HTML>" +
"<ListProperty Select=\"Title\" HTMLEncode=\"TRUE\" />" +
"<HTML>\" list have been completed. See </HTML>" +
"<HTML><![CDATA[<A HREF=\"]]></HTML>" +
"<HttpVDir URLEncode=\"TRUE\"/>" +
"<HTML><![CDATA[/Lists/Announcements/AllItems.aspx\">]]></HTML>" +
"<HTML>Announcements</HTML><HTML><![CDATA[</A>]]></HTML>" +
"<HTML> for details.</HTML>" +
"<HTML><![CDATA[</TD>]]></HTML></Then><Else>" +
"<HTML><![CDATA[<TD class=\"ms-vb\"><B>]]></HTML>" +
"<HTML>No records were found matching your query.</HTML>" +
"<HTML><![CDATA[</B></TD>]]></HTML>" +
"</Else></IfEqual><HTML><![CDATA[</TR></TABLE>]]></HTML>" +
"<HTML><![CDATA[</td></tr></TABLE>]]></HTML>";
XmlNode ndViewEmpty = xmlDoc.CreateNode(XmlNodeType.Element,"ViewEmpty","");
ndViewEmpty.InnerXml = strViewEmpty;
viewService.UpdateViewHtml("List_Name", "9781bd25-1f68-481f-81d3-1e4f3f9216dd", null, null, null, null, null, ndViewEmpty, null, null, null, null, null, null);