Click to See Complete Forum and Search --> : Dynamic array off System.IO.Directory.GetFiles to populate Ajax SlideShow in MasterPa


Corinthian
February 3rd, 2008, 05:26 AM
I'm on day two of trying to fight my way through this... I cry 'uncle'

I'm using the Ajax SlideShowExtender to play images in a navigational element. My site is .Net 2.0, C#. I use MasterPages. All code pertaining to this SlideShow functionality is in the MasterPage.

I call System.IO.Directory.GetFiles to parse through a directory and create an array of the contents of my image folder. I've suffered through dozens of different errors of the hours-- BUT WHAT IS EXTREMELY IMPORTANT TO NOTE, is that outside of the Master/Content page structure, every bit of code functions properly. I take this to mean that I don't know how to path to the directory from the master or something like that-- though I've tried a million ways.

Can someone please help me?

again, this code that fails when executed through the master, runs perfectly if I put it in a new page without the master/content structure.

5 years of good luck to the one who keeps me from losing anymore sleep on this.

relevant code blocks below:

MasterPage.Master.cs

[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
public static AjaxControlToolkit.Slide[] GetSlides(string contextKey)
{
string[] fileNames = System.IO.Directory.GetFiles(@"C:\Documents and Settings\Corinthian\My Documents\Visual Studio 2005\WebSites\SistersEstates\images\");
AjaxControlToolkit.Slide[] photos = new AjaxControlToolkit.Slide[fileNames.Length];
for (int i = 0; i < fileNames.Length; i++)
{
string[] file = fileNames[i].Split('\\');
photos[i] = new AjaxControlToolkit.Slide("images/" + file[file.Length - 1], "", "");
}

return photos;

}



from MasterPage.Master

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True">
</asp:ScriptManager>
<br />

<cc1:SlideShowExtender ID="SlideShowExtender1" runat="server"
SlideShowServiceMethod="GetSlides"
TargetControlID="Image1"
AutoPlay="true" Loop="true"
UseContextKey="True">
</cc1:SlideShowExtender>

<asp:Image ID="Image1" runat="server" />