I need to set up the slide show based on a querystring parameter. I thought I had this figured out, but I clearly don't understand something about how the webservice works.
I have this in the .aspx page:
<asp:Button ID="btnPrev" runat="server" Text="Prev" />
<asp:Button ID="btnPlay" runat="server" Text="Play" />
<asp:Button ID="btnNext" runat="server" Text="Next" />
<asp:Label ID="lblDesc" runat="server" />
<cc1:SlideShowExtender ID="SlideShowExtender1" runat="server" BehaviorID="SSBehaviorID"
TargetControlID="tstSlides"
AutoPlay="true"
ImageDescriptionLabelID="lblDesc"
NextButtonID="btnNext"
PreviousButtonID="btnPrev"
PlayButtonID="btnPlay"
PlayButtonText="Play"
StopButtonText="Stop"
Loop="true" >
</cc1:SlideShowExtender>
<asp:Image ID="tstSlides" runat="server" height="300px" Width="300px" />
And this in the code behind:
Dim smate As String = "z-404932"
'Create new array of valid file names from FileInfo
Dim dir As New DirectoryInfo(HttpContext.Current.Request.ServerVariables("APPL_PHYSICAL_PATH").ToString() & "images\picts\")
Dim files As FileInfo() = dir.GetFiles(smate & "*.jpg")
Dim nLength As Integer = Len(smate)
Dim newFiles As New ArrayList()
For Each file As FileInfo In files
If Mid(file.Name, nLength + 1, 1) = "-" Or Mid(file.Name, nLength + 1, 1) = "." Then
newFiles.Add(file.Name)
End If
Next
'now sort the arraylist
newFiles.Sort()
'now see if we have anything
If newFiles.Count = 0 Then
newFiles(0) = "no-photo.jpg"
End If
tstSlides.ImageUrl = "../images/picts/" & newFiles(0)
SlideShowExtender1.SlideShowServiceMethod = "GetSlides()"
Also in the code behind is the webservice:
<System.Web.Services.WebMethod(), System.Web.Script.Services.ScriptMethod()> _
Public Shared Function GetSlides() As AjaxControlToolkit.Slide()
Dim imgSlide(3) As AjaxControlToolkit.Slide
imgSlide(0) = New AjaxControlToolkit.Slide("../images/picts/z-404932.jpg", "Autumn", "Autumn Leaves")
imgSlide(1) = New AjaxControlToolkit.Slide("../images/picts/z-404932-2.jpg", "Creek", "Creek")
imgSlide(2) = New AjaxControlToolkit.Slide("../images/picts/z-404932-3.jpg", "Landscape", "Landscape")
imgSlide(3) = New AjaxControlToolkit.Slide("../images/picts/z-404932-4.jpg", "Dock", "Dock")
Return (imgSlide)
smate is hardcoded for testing, it will be a querystring. Now this all works fine. I have no problem setting tstSlides.ImageUrl or SlideShowExtender1.SlideShowServiceMethod in the code behind. But now I want to pass in newFiles. But to simplify things for now, I could get by with passing in a simpler variale, smate. So I add the parameters as so:
SlideShowExtender1.SlideShowServiceMethod = "GetSlides(smate)"
and
<System.Web.Services.WebMethod(), System.Web.Script.Services.ScriptMethod()> _
Public Shared Function GetSlides(ByVal smate As String) As AjaxControlToolkit.Slide()
Dim imgSlide(3) As AjaxControlToolkit.Slide
imgSlide(0) = New AjaxControlToolkit.Slide("../images/picts/z-404932.jpg", "Autumn", "Autumn Leaves")
imgSlide(1) = New AjaxControlToolkit.Slide("../images/picts/z-404932-2.jpg", "Creek", "Creek")
imgSlide(2) = New AjaxControlToolkit.Slide("../images/picts/z-404932-3.jpg", "Landscape", "Landscape")
imgSlide(3) = New AjaxControlToolkit.Slide("../images/picts/z-404932-4.jpg", "Dock", "Dock")
Return (imgSlide)
Note that I haven't changed anything in the webservice yet except for the new parameter. The slideshow no longer works. What am I not understanding?