Second Life of a Hungarian SharePoint Geek

December 20, 2009

Addressing the Edit View page from code

Filed under: SharePoint, Views — Tags: , — Peter Holpar @ 03:58

The Edit View page is easy to access from the user interface by clicking the Modify this View item in the menu.

It is a bit harder to get the correct URL programmatically. The following code snippet will show you how to solve this issue:

  1. SPView view = web.Lists["Tasks"].Views["All Tasks"];
  3. String url = String.Format("{0}/_layouts/ViewEdit.aspx?List={1}&View={2}&Source={3}",
  4.     SPContext.Current.Site.Url,
  5.     SPEncode.UrlEncode(view.ParentList.ID.ToString("B").ToUpper()),
  6.     SPEncode.UrlEncode(view.ID.ToString("B")).ToUpper(),
  7.     SPEncode.UrlEncode(SPEncode.UrlEncode(SPContext.Current.Web.Url + view.ServerRelativeUrl))).ToUpper();

In the example above I get the URL of the page that edits the All Tasks view in the Tasks list. Of course, if you need the URL of other views, you should replace the name of the list and the view.


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: