I am trying to use the SlideShowExtender in toolkit and I get the following error.
An unhandled exception occurred:
Message: Unknown web method GetSlides.
Parameter name: methodName
Stack Trace:
at System.Web.Script.Services.WebServiceData.GetMethodData(String methodName)
at System.Web.Script.Services.RestHandler.CreateHandler(WebServiceData webServiceData, String methodName)
at System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)
at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Below is my markup and webmethod
<asp:Image ID="ImgSlide" runat="server" Height="300" Width="300" />
<ajaxToolkit:SlideShowExtender ID="SlideShowExtender1" runat="server"
TargetControlID="ImgSlide"
SlideShowServiceMethod="GetSlides"
SlideShowServicePath="~/WebServiceImages.asmx"
AutoPlay="True"
PlayInterval="1000" />
Imports System.IO
Imports AjaxControlToolkit
Imports System.Web.Services
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<System.Web.Script.Services.ScriptService()>
<WebService(Namespace:="http://tempuri.org/")>
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)>
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Public Class WebServiceImages
Inherits System.Web.Services.WebService
<WebMethod()>
Public Shared Function GetSlides() As Slide()
Dim slides As New List(Of Slide)()
Dim sPath As String = HttpContext.Current.Server.MapPath("~/ketodocs/slides/")
If sPath.EndsWith("\") Then
sPath = sPath.Remove(sPath.Length - 1)
End If
Dim pathUri As New Uri(sPath, UriKind.Absolute)
Dim files As String() = Directory.GetFiles(sPath)
For Each file As String In files
Dim filePathUri As New Uri(file, UriKind.Absolute)
slides.Add(New Slide() With {
.Name = Path.GetFileNameWithoutExtension(file),
.Description = Path.GetFileNameWithoutExtension(file) + " Description.",
.ImagePath = pathUri.MakeRelativeUri(filePathUri).ToString()
})
Next
Return slides.ToArray()
End Function
End Class
That ALMOST worked. The error went away but the image returned was placed after the </form> tag with style="display=none;" when using using F12 developer tools.
That ALMOST worked. The error went away but the image returned was placed after the </form> tag with style="display=none;" when using using F12 developer tools.
Can you see anything that would cause that?
No, that worked. This is a different issue.
Have you tried placing a breakpoint in the web method to verify the web method is operating as expected? I would assume you have more than one image returned or should have more than one.
I can't see the markup so I have no idea if you have everything setup correctly. I did a quick google and found these.
Below is my markup and it is pretty simple but still no images appear, only a box outline where the image should be.
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div id="slideshow" runat="server" class="row">
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 img-responsive">
<asp:Image ID="ImgSlide" runat="server" Height="300" Width="300" />
<ajaxToolkit:SlideShowExtender ID="SlideShowExtender1" runat="server"
TargetControlID="ImgSlide"
SlideShowServiceMethod="GetSlides"
SlideShowServicePath="~/WebServiceImages.asmx"
AutoPlay="True"
PlayInterval="1000" />
</div>
</div>
</form>
Below is web service code
Imports System.IO
Imports AjaxControlToolkit
Imports System.Web.Services
Imports System.Web.Script.Services
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<System.Web.Script.Services.ScriptService()>
<WebService(Namespace:="http://tempuri.org/")>
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)>
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Public Class WebServiceImages
Inherits System.Web.Services.WebService
<WebMethod()>
Public Function GetSlides() As AjaxControlToolkit.Slide()
Dim slides As New List(Of Slide)()
Dim sPath As String = HttpContext.Current.Server.MapPath("~/ketodocs/")
If sPath.EndsWith("\") Then
'sPath = sPath.Remove(sPath.Length - 1)
End If
sPath &= "\slides"
Dim pathUri As New Uri(sPath, UriKind.Absolute)
Dim files As String() = Directory.GetFiles(sPath)
For Each file As String In files
Dim filePathUri As New Uri(file, UriKind.Absolute)
slides.Add(New Slide() With {
.Name = Path.GetFileNameWithoutExtension(file),
.Description = Path.GetFileNameWithoutExtension(file) + " Description.",
.ImagePath = pathUri.MakeRelativeUri(filePathUri).ToString()
})
Next
Return slides.ToArray()
End Function
End Class
According to your codes, I found the image path you have set in the GetSlides web method is wrong.
It will only return image file name to the client-side.
I suggest you could try to add the image folder at the root of the application and use below codes:
Webmethod:
<WebMethod()>
Public Function GetSlides() As AjaxControlToolkit.Slide()
Dim slides As New List(Of Slide)()
Dim sPath As String = HttpContext.Current.Server.MapPath("~/ketodocs/")
If sPath.EndsWith("\") Then
'sPath = sPath.Remove(sPath.Length - 1)
End If
sPath &= "slides\"
'Dim pathUri As New Uri(sPath, UriKind.Absolute)
Dim files As String() = Directory.GetFiles(sPath)
For Each file As String In files
'Dim filePathUri As New Uri(file, UriKind.Absolute)
slides.Add(New Slide() With {
.Name = Path.GetFileNameWithoutExtension(file),
.Description = Path.GetFileNameWithoutExtension(file) + " Description.",
.ImagePath = "ketodocs/slides/" + Path.GetFileName(file)
})
Next
Return slides.ToArray()
End Function
Result:
Best Regards,
Brando
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Tried your code but still not getting images. The hidden img tag (created by extender?) has a src=undefined rather than the path of src=ketodocs/slides/imagefile.jpg
I am also trying to do this with just code-behind on page as below. Also note that ketodocs is a virtual folder off the root.
Imports System.IO
Imports AjaxControlToolkit
Imports System.Web.Services
Imports System.Web.Script.Services
Imports System.Collections.Generic
Partial Class KetoStartNew
Inherits System.Web.UI.Page
<WebMethod()>
Public Function GetSlides() As AjaxControlToolkit.Slide()
Dim slides As New List(Of Slide)()
Dim sPath As String = HttpContext.Current.Server.MapPath("~/ketodocs/")
If sPath.EndsWith("\") Then
'sPath = sPath.Remove(sPath.Length - 1)
End If
sPath &= "slides\"
'Dim pathUri As New Uri(sPath, UriKind.Absolute)
Dim files As String() = Directory.GetFiles(sPath)
For Each file As String In files
'Dim filePathUri As New Uri(file, UriKind.Absolute)
slides.Add(New Slide() With {
.Name = Path.GetFileNameWithoutExtension(file),
.Description = Path.GetFileNameWithoutExtension(file) + " Description.",
.ImagePath = "ketodocs/slides/" + Path.GetFileName(file)
})
Next
Return slides.ToArray()
End Function
End Class
Member
353 Points
1551 Posts
SlideShow method error
May 11, 2018 06:34 PM|dlchase|LINK
I am trying to use the SlideShowExtender in toolkit and I get the following error.
An unhandled exception occurred:
Message: Unknown web method GetSlides.
Parameter name: methodName
Stack Trace:
at System.Web.Script.Services.WebServiceData.GetMethodData(String methodName)
at System.Web.Script.Services.RestHandler.CreateHandler(WebServiceData webServiceData, String methodName)
at System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)
at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Below is my markup and webmethod
All-Star
53041 Points
23619 Posts
Re: SlideShow method error
May 11, 2018 07:06 PM|mgebhard|LINK
Removed "Shared" from the web method declaration. ASMX uses instance methods unlike web method in an ASPX page.
Member
353 Points
1551 Posts
Re: SlideShow method error
May 11, 2018 07:56 PM|dlchase|LINK
That ALMOST worked. The error went away but the image returned was placed after the </form> tag with style="display=none;" when using using F12 developer tools.
Can you see anything that would cause that?
All-Star
53041 Points
23619 Posts
Re: SlideShow method error
May 11, 2018 08:23 PM|mgebhard|LINK
No, that worked. This is a different issue.
Have you tried placing a breakpoint in the web method to verify the web method is operating as expected? I would assume you have more than one image returned or should have more than one.
I can't see the markup so I have no idea if you have everything setup correctly. I did a quick google and found these.
https://www.experts-exchange.com/questions/25071859/AJAX-SlideShow.html
http://www.dotnetcurry.com/ShowArticle.aspx?ID=287
Member
353 Points
1551 Posts
Re: SlideShow method error
May 15, 2018 02:25 PM|dlchase|LINK
Below is my markup and it is pretty simple but still no images appear, only a box outline where the image should be.
Member
353 Points
1551 Posts
Re: SlideShow method error
May 15, 2018 09:42 PM|dlchase|LINK
Also, this might help, the img tag results in a src=undefined.
Star
9831 Points
3120 Posts
Re: SlideShow method error
May 16, 2018 10:11 AM|Brando ZWZ|LINK
Hi dlchase,
According to your codes, I found the image path you have set in the GetSlides web method is wrong.
It will only return image file name to the client-side.
I suggest you could try to add the image folder at the root of the application and use below codes:
Webmethod:
Result:
Best Regards,
Brando
Member
353 Points
1551 Posts
Re: SlideShow method error
May 16, 2018 01:44 PM|dlchase|LINK
Tried your code but still not getting images. The hidden img tag (created by extender?) has a src=undefined rather than the path of src=ketodocs/slides/imagefile.jpg
I am also trying to do this with just code-behind on page as below. Also note that ketodocs is a virtual folder off the root.
And page (.aspx) markup as below.
Member
353 Points
1551 Posts
Re: SlideShow method error
May 16, 2018 02:27 PM|dlchase|LINK
Nevermind...I fixed it from a typo. Thanks.