locked
SharePoint 2010 custom web part with intranet and internet RRS feed

  • Question

  • Hi,

    I have a publishing site with several custom web parts. The portal should be accessed by internal employees through intranet and by customers through internet.

    I have some predefined lists and image libraries within the site. Now i need to pass the list URL as a web part property to access that list and to do some business logic in it.

    Now the problem is employees are going to access the site by using a different URL and the customers are going to access the site by using different URL. Now how can i put a common URL within my web part property so that it works on both the cases.

    I tried with the http://localhost/Technical/ but it's not working as expected.

    Could you please help me here?


    Kathir

    Friday, June 1, 2012 10:35 AM

Answers

  • Hello KarurKathir,

    I You use server relative url of the list in the webpart property.

    Like Wepart Property value is listurl = "Lists/ListUrl/AllItems.aspx"

    and try to access the list with

    SPWeb.GetListFromUrl(listurl);

    Hope this helps.

    -Saumil

    • Marked as answer by Shimin Huang Friday, June 8, 2012 9:28 AM
    Friday, June 1, 2012 2:35 PM
  • Deleted
    • Marked as answer by Shimin Huang Friday, June 8, 2012 9:28 AM
    Friday, June 1, 2012 6:50 PM

All replies

  • How about providing only relative path of List URL?

    -Prashant

    Friday, June 1, 2012 10:39 AM
  • Hi,

    When i pass the relative URL i am getting the below error message.

    Error Invalid URI: The format of the URI could not be determined.


    Kathir

    Friday, June 1, 2012 11:04 AM
  • Ok. But if this is a text type of webpart property which you are reading in webpart code, then you can very well append the web application URL or root site URL which can be stored as configuration key in web.config of the web application.

    -Prashant

    Friday, June 1, 2012 12:01 PM
  • Hello KarurKathir,

    I You use server relative url of the list in the webpart property.

    Like Wepart Property value is listurl = "Lists/ListUrl/AllItems.aspx"

    and try to access the list with

    SPWeb.GetListFromUrl(listurl);

    Hope this helps.

    -Saumil

    • Marked as answer by Shimin Huang Friday, June 8, 2012 9:28 AM
    Friday, June 1, 2012 2:35 PM