Sharepoint 2010 Answers

 
Home » Forum » Sharepoint 2010       Ask a questionRSS Feeds
  Question Asked By: Shradha Shrestha   on Aug 05, 2010 In Sharepoint 2010 Category.

 
Question Answered By: Jordon Willis   on Aug 05, 2010

Are you able to get Image Path correctly? I have a feeling you are not getting Image Path correctly. I have made minor change to your code. Let me know if that works for you. Incase it didn't let me know at what point it is failing.


if (pubPage != null  && pubPage.Layout.Title == "ABCHome page  Layout")
{

//Get the list
SPList HomepageImage = currentWeb.Lists["Homepage Images"];

//Get the list  items
SPListItemCollection collListItems = HomepageImage.Items;

string strBannerImage = HomepageImage.Items[random.Next(0, collListitems.Count - 1)].Url;


//Select one of the list items  
Random random  = new Random();
bannerImage = "<img src='" + strBannerImage + "'>";

break;
}

Tagged:                

 

This Question has 5 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Display Publishing Image to the page from a SPList Or get search suggestion and latest updates.