SPWeb.GetViewFromUrl Method
Gets a view of a list within the site based on the specified URL.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
Parameters
- listUrl
- Type: System.String
The absolute or site-relative URL of the list for which the view is retrieved.
| Exception | Condition |
|---|---|
| ArgumentNullException |
listUrl is null. |
The following code example uses the GetViewFromUrl method to return a view and uses the view to return and display items.
using (SPWeb oWebsite = SPContext.Current.Site.OpenWeb("Website_URL")) { SPList oList = oWebsite.Lists["List_Name"]; SPView oView = oWebsite.GetViewFromUrl("Lists/List_Name/View_Name.aspx"); SPListItemCollection collListItems = oList.GetItems(oView); Response.Write(SPEncode.HtmlEncode(collListItems.Xml)); }
Note |
|---|
Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects. |
Note