ajax slideshow calling webservice with parameter

Asked By Andy Kalbvleesch
17-Aug-09 01:13 PM
Earn up to 0 extra points for answering this tough question.

I want to use the ajax slideshow extender and got so far to use it with calling a range of images from database by coding an ID hard in the webservice. However I want to be able to pass a parameter to tthe webservice so I can get specific images. Code is below... Anybody ?

Code in aspx:

            <ajaxToolkit:SlideShowExtender ID="slideshowextend1" runat="server"
                TargetControlID="Image1"
                SlideShowServicePath="slidesservice.asmx"
                SlideShowServiceMethod="GetSlides"
                AutoPlay="true"
                ImageDescriptionLabelID="imageLabel1"
                NextButtonID="nextButton"
                PlayButtonText="Play"
                StopButtonText="Stop"
                PreviousButtonID="prevButton"
                PlayButtonID="playButton" />

 

Webservice:
Imports System.Web.Services.Protocols

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
<System.Web.Script.Services.ScriptService()> _
Public Class SlidesService
    Inherits System.Web.Services.WebService

    <WebMethod()> _
   Public Function GetSlides() As AjaxControlToolkit.Slide()
        Dim ds As System.Web.UI.WebControls.SqlDataSource = New SqlDataSource()
        ds.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("apuraprovider")
        Dim mySelect As String
        Dim count As Integer = 0
        mySelect = "SELECT objectenfotos.object_ID, objecten.klant_ID, objectenfotos.fotonaam, objectenfotos.omschrijving " & _
        "FROM objectenfotos INNER JOIN objecten ON objectenfotos.object_ID = objecten.object_ID " & _
        "where objecten.klant_ID = myparameter

        ds.SelectCommand = mySelect
        Dim dv As System.Data.DataView = DirectCast(ds.[Select](New DataSourceSelectArguments()), System.Data.DataView)
        count = dv.Table.Rows.Count
        Dim slides As AjaxControlToolkit.Slide() = New AjaxControlToolkit.Slide(count - 1) {}
        Try
            For i As Integer = 0 To count - 1
                slides(i) = New AjaxControlToolkit.Slide("uploadlogos/mid/" & dv.Table.Rows(i)("fotonaam").ToString(), dv.Table.Rows(i)("fotonaam").ToString(), dv.Table.Rows(i)("omschrijving").ToString())
            Next
        Catch
            'some errorhandling
        End Try
        Return (slides)
    End Function

End Class

 

 

 

 

  Use the ContextKey to pass arguments to the webservice. It is a two-step process.

[)ia6l0 iii replied to Andy Kalbvleesch
17-Aug-09 02:16 PM
Step 1: add the UseContextKey and the ContextKey attributes.
<ajaxToolkit:SlideShowExtender ID="slideshowextend1" runat="server" 
                TargetControlID="Image1" 
                SlideShowServicePath="slidesservice.asmx"
                SlideShowServiceMethod="GetSlides" 
                AutoPlay="true" 
                ImageDescriptionLabelID="imageLabel1"
                NextButtonID="nextButton" 
                PlayButtonText="Play" 
                StopButtonText="Stop"
                PreviousButtonID="prevButton" 
                PlayButtonID="playButton"
UseContextKey="true" ContextKey="parametervalue"/>

Step 2: modify the function like this.
.....
<WebMethod()> _
   Public Function GetSlides(ByVal contextKey As String) As AjaxControlToolkit.Slide()
        Dim ds As System.Web.UI.WebControls.SqlDataSource = New SqlDataSource()
        ds.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("apuraprovider")
        Dim mySelect As String
        Dim count As Integer = 0
        mySelect = "SELECT objectenfotos.object_ID, objecten.klant_ID, objectenfotos.fotonaam, objectenfotos.omschrijving " & _
        "FROM objectenfotos INNER JOIN objecten ON objectenfotos.object_ID = objecten.object_ID " & _
        "where objecten.klant_ID = 
myparameter
         where objecten.klant_ID = contextKey
......

  ajax slideshow

mv ark replied to Andy Kalbvleesch
18-Aug-09 01:00 AM
For a lightweight option to run a AJAX slideshow, consider using a jQuery slideshow plugin like Cycle along with a Generic HTTP Handler (.ashx) -
http://jonraasch.com/blog/a-simple-jquery-slideshow
http://www.eggheadcafe.com/tutorials/aspnet/b8381915-06d9-4538-b4bb-5ac2a8e73f34/implementing-continuous-s.aspx
Create New Account