kamagra how much to take

SPListItem.URL Funky Return Fiesta

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.

  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? :)

Share

10 Comments

  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. 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.

  5. 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!

  6. 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

  7. Hal Diggs says:

    coolio, just what i was looking for.

  8. Daniel Revell says:

    Seems to work for me. Might some people be getting problems with the Url if they’re using a customer display form? In which case the form might be stored inside the pages list.

    I’m just guessing here. I’ve not used customer display forms yet.

  9. Robert Beard says:

    Hi,

    Not sure if this helps anyone at this point, but depending on whether or not the default dispform has been changed for the list item’s content type, this might help resolve the proper display form.

    Once you have the list item, you can get the content type of the item and check the DisplayFormUrl before using the PAGE_DISPLAYFORM. For example,

    SPListItem listItem = list.GetItemById( itemId );

    SPContentType contentType = listItem.ContentType;

    string urlToItem = type.DisplayFormUrl;

    if(String.IsNullOrEmpty(urlToItem))

  10. adam says:

    Great tip Robert!

Trackbacks/Pingbacks

  1. Blogger Loser » Blog Archive » SPListItem.URL Funky Return Fiesta - [...] Man, I have never seen this before, but doing a simple SPListItem.URL and returning the URL returns a funky …
  2. Links (8/28/2007) « Steve Pietrek’s SharePoint Stuff - [...] SPListItem.URL Funky Return Fiesta [...]
  3. SPListItem Url | blog.richardramdat.com - [...] http://www.sharepointsecurity.com/sharepoint/sharepoint-development/splistitemurl-funky-return-fiest... [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>