Second Life of a Hungarian SharePoint Geek

December 20, 2009

Addressing a personal view page from code

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

When a shared view is created in SharePoint, a new .aspx file having the name of the view is created.

It’s a bit different, when you create a personal view. In this case a page called PersonalViews.aspx is used to display the view to the user. To enable the page to display different views for the same or to other users, a query string parameter called ShowWebPart is used to specify the GUID of the view in the {dddddddd-dddd-dddd-dddd-dddddddddddd} format.

Beyond this parameter, there is an additional query string parameter called PageView that has the constant value of Personal.

The following code snippet illustrates how to redirect the page to a specific personal list assuming you created one in the Tasks list and it is called My View.

  1. SPView myView = web.Lists["Tasks"].Views["My View"];
  2. if ((myView != null) && (myView.PersonalView))
  3. {
  4.     String urlToRedirect = String.Format("{0}?PageView=Personal&ShowWebPart={{{1}}}", myView.Url, myView.ID);
  5.     Response.Redirect(urlToRedirect);
  6.     // or you can use SPUtility.Redirect as well, like
  7.     // SPUtility.Redirect(urlToRedirect, SPRedirectFlags.Default, HttpContext.Current);
  8. }

Although we could use the constant PersonalViews.aspx view page name, I think it is a better practice to get the name (and the whole address) from the Url property of the view.



  1. Hi
    I have implemented your code but its not workking.All I want user to see their personal view from a sharepoint list using click events.’

    Any help would be appriciated ,here is my code below.

    using (SPSite site = new SPSite(WorkFlowSite))
    SPView myView = site.OpenWeb().Lists[“Release Request”].Views[“MyView”];
    if (myView != null && (myView.PersonalView))
    string redirectUrl = String.Format(“PersonalViews.aspx?PageView=Personal&ShowWebPart={AAF1AE67-0057-4E4A-9871-A30F49794B74}”, myView.Url, myView.ID);


    Comment by moss — November 11, 2010 @ 19:14

    • Hi,

      If you hard-coded view URL and ID in the redirectUrl, why do you use String.Format?
      What do you mean “not working”? Is there an error (if so, what error you receive and at which line), or it simply does nothing. I suggest to debug your code first to see what happens.


      Comment by Peter Holpar — December 2, 2010 @ 22:46

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: