Posted by Adam Buenz

Man, I have never seen this before, but doing a simple SPListItem.URL and returning the URL returns a funky ass value. It looks like hex or some crap, like this:

http://localhost/lists/MyList/6_.000

What the hell is that? Shouldn't the SPListItem.Url property return the actual URL to the item?

To get around this, you have to tailor your code a little bit differently.

C#:
  1. SPList list = site.Lists.GetList("MyList");
  2.  
  3. SPListItem item = list.Items[id];
  4.  
  5. list.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url + "?ID=" + item.ID

Now you will actual retrieve the correct path to the DispForm.aspx page.

Wierd, eh? :)

8 Responses to “SPListItem.URL Funky Return Fiesta”

  1. Stacy Draper Says:

    Man that is so weird!

  2. Renaud Comte Says:

    In fact this property works only for Doc items ...

  3. Adam Buenz Says:

    That, I didn't know. Thanks for the tip Renaud!

  4. Blogger Loser » Blog Archive » SPListItem.URL Funky Return Fiesta Says:

    [...] Man, I have never seen this before, but doing a simple SPListItem.URL and returning the URL returns a funky ass value. It looks like hex or some crap, like this: http://localhost/lists/MyList/6_.000 What the hell is that? Shouldn't the SPListItem Read More……(read more) [...]

  5. Links (8/28/2007) « Steve Pietrek’s SharePoint Stuff Says:

    [...] SPListItem.URL Funky Return Fiesta [...]

  6. Menno Says:

    Interestingly enough, the List.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url code returns someting fishy for me too:
    I get http://tabeokaser001/test_menno/Pages/Lists/TEST/DispForm.aspx, while the correct url is http://tabeokaser001/test_menno/Lists/TEST/DispForm.aspx?ID=1 (without 'Pages').
    I think I'll fiddle with PAGETYPE.PAGE_DISPLAYFORM some more, and see what I can come up with.

  7. Adam Buenz Says:

    Well part of that makes sense, you should get that unless you are appending the + "?ID=" + item.ID so that it is aware of which SPListItem ID to point to. The other part, where it is truncated "Pages" out of the name, I don't know where it comes from.

    I have also noticed that sometimes it does not work on custom list types, which is weird, because it should. If you can post back your results it would be appreciated!

  8. Djavan ROA Says:

    Hi, thx it helped me out.

    Worked with my custom list but I had to change it a bit to not get the /Pages/ before.

    myList.Forms[PAGETYPE.PAGE_DISPLAYFORM].ServerRelativeUrl + "?ID=" + myItem.ID

Leave a Reply