Introduction:
Here I will explain how to solve the problem Microsoft JScript runtime error: Sys.Net.WebServiceFailedException: The server method 'GetSlides' failed with the following error: during use of Ajax Slideshow extender control to display images from root folder using asp.net
Description:
Here I will explain how to solve the problem Microsoft JScript runtime error: Sys.Net.WebServiceFailedException: The server method 'GetSlides' failed with the following error: during use of Ajax Slideshow extender control to display images from root folder using asp.net
Description:
In previous post I explained clearly how to show slideshow using AjaxSlideshowExtender control from root folder in asp.net check here . During working with Ajax SlideshowExtender I got error like
Microsoft JScript runtime error: Sys.Net.WebServiceFailedException: The server method 'GetSlides' failed with the following error: <html><head>
To solve this problem I check my code and I found my mistake that problem is because of I forgot to declare the WebMethod and ScriptMethod
We need to write webmethods in below format only and use exact parameters that should be same as whatever I mentioned in web method
[System.Web.Services.WebMethod] [System.Web.Script.Services.ScriptMethod] public AjaxControlToolkit.Slide[] GetSlides() { …… …… } |
In this web method we have a chance to change GetSlides method name only but return type and parametername should match and don’t forgot to mention this WebMethod and ScriptMethod above our GetSlides method the exception occurred because of missing these webmethods declaration.
Sometimes this problem occurs because of below line missing in code also
[System.Web.Script.Services.ScriptService] |
By default this line is commented in webservice page we need to uncomment that line.
If we need to get the slideshow webservice method without errors our webservice page code looks like this
/// <summary> /// Summary description for Slideshow /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. [System.Web.Script.Services.ScriptService] public class Slideshow : System.Web.Services.WebService { public Slideshow () { //Uncomment the following line if using designed components //InitializeComponent(); } [System.Web.Services.WebMethod] [System.Web.Script.Services.ScriptMethod] public AjaxControlToolkit.Slide[] GetSlides() { string[] imagenames = System.IO.Directory.GetFiles(Server.MapPath("~/Images")); AjaxControlToolkit.Slide[] photos = new AjaxControlToolkit.Slide[imagenames.Length]; for (int i = 0; i < imagenames.Length; i++) { string[] file = imagenames[i].Split('\\'); photos[i] = new AjaxControlToolkit.Slide("Images/" + file[file.Length - 1], file[file.Length - 1], ""); } return photos; } } |
I hope it helps to solve your problem.
Happy Coding……….
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
7 comments :
I have done as you suggested but still I am getting the error.
I am trying load the user control dynamically. User control has lot of complex code Repeater inside repeater so many action button.
your codes helped more... thankyou
its still giving same error..
plz help me to solve it!
The error problem still exist.
I can not find the differences.
i had the same issue, i was calling a webservice method from javascript and got the error
Sys.Net.WebServiceFailedException: The server method '' failed with the following error:
it can be solved by adding following lines to web.config
stackoverflow(dot)com(slash)a(slash)1151993/1054978
Note: Only a member of this blog may post a comment.