Views.UpdateViewHtml Method
[SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/UpdateViewHtml", RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace="http://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
A string that contains the internal name of the list.
- viewName
A string that contains the GUID for the view.
- viewProperties
An XML fragment that contains all view-level properties as attributes, such as Editor, Hidden, ReadOnly, and Title.
- toolbar
A 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:
- viewHeader
A 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:
- viewBody
A 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:
- viewFooter
A 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:
- viewEmpty
A 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:
- rowLimitExceeded
A 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:
- query
A 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:
- viewFields
A 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:
- aggregations
An Aggregations element that specifies the fields to aggregate and that can be assigned to a System.Xml.XmlNode object, as in the following example:
- formats
A 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:
- rowLimit
A 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:
Return Value
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="http://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>
To modify only the query and field definitions in a view, use the UpdateView method.
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.
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);