Try our conversational search powered by Generative AI!

obtain PageReference from linkcollection item


I need to read properties from the pages added to a Link Colection

Any ideea how could I obtain a reference to each page in a Link Collection property?

I have the link to the page in the LinkItem object how can i use it or maybe if there is any other way please let me know


Jan 14, 2009 12:56


 If the LinkItem.Href is not a friendly url, I suppose you could substring it and get the id?

Jan 14, 2009 16:01
I've never used the LinkCollection, but if you have a URL you can parse it by PageReference.ParseUrl(...);
Jan 14, 2009 17:32

or by
PageReference res = PermanentLinkUtility.GetPageReference(new UrlBuilder(url));

If you use Itera.MultiProperty you can loop over the item like this:

<Itera:Property ID="Property2" runat="server" PropertyName="LinksRelaterte.Links" SuppressEmpty=false >
            Href={this.Href}<br />
            PageReference={this.Href.ToPageData()}<br />
            PageLink={this.Href.ToPageData().LinkURL}<br />
            PageName={this.Href.ToPageData().PageName}<br />
           Text={this.Text}<br />
           Target={this.Target}<br />

This will generate output like:
The Norwegian Embassy, Tokyo Href=~/link/f4fb6b10a78c425fbf4febf6830bd8af.aspx?epslanguage=en
Text=The Norwegian Embassy, Tokyo

Edited, Jan 14, 2009 18:37

thanks for the answers

my solution was to get the GUID of the page in order to use this

PermanentLinkUtility.FindPageReference(new Guid(sGuid)) 

but this was a temporary solution, i really wanted to use 

PageReference res = PermanentLinkUtility.GetPageReference(new UrlBuilder(url)); 

where url i thought it would be the  LinkItemCollection.LinkItem.Href but this didn't worked as expected

I am using LinkItemCollection and the target objects are LinkItem objects

It would be nice if there was a method like in your example : Href.ToPageData()


Jan 15, 2009 11:50

Also PageReference.ParseUrl is not helping i get a pagereference with ID 0  every time

The LinkItem.href looks something like this ~/Link/SomeGuid.aspx

Jan 15, 2009 11:55


Maybe this answer comes a little bit late, but I think I have found a small solution to this. The I found the secret solution in the method:  PermanentLinkMapStore.TryToMapped(linkItem.Href, out selectedOutPutString);

 So what I did for short was to first get the PropertyLinkCollection, then started to loop through all the LinkItems. My purpose was only to get hold of the pages and not documents, external links, but these could easily also be handled. See my solution below:


// Create a new PageDataCollection
            PageDataCollection indexPages = new PageDataCollection();

            // Get the property
            PropertyLinkCollection propertyIndexPages = CurrentPage.Property["IndexPages"] as PropertyLinkCollection;
            // Make sure it is not null
            if (propertyIndexPages != null)
                // Loop through all the links in the property
                foreach (LinkItem link in propertyIndexPages.Links)
                    // Create the output strin
                    string linkUrl = string.Empty;
                    // Try to map the link
                    PermanentLinkMapStore.TryToMapped(link.Href, out linkUrl);
                    // Make sure there is a link, Externa urls will not be mapped, but documents will.
                    if (!string.IsNullOrEmpty(linkUrl))
                        // Try to cast to a PageReference
                        PageReference pageRef = PageReference.ParseUrl(linkUrl);
                        // In this case only add Pages, you could here also handle documents



Hope this could help a little bit.



Feb 10, 2009 10:51

thanks gustaf.

your little piece of code helped me out.

sweet as!

May 04, 2009 19:37
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.