Answered by:
Ajax static method in master page

Question
-
User1078715821 posted
I have below coding to show a slideshow in MasterPage
<asp:Panel ID="Panel5" runat="server" Width="700px" Height="150px"> <asp:Image runat="server" ID="img" Width="700px" Height="150px" /> <asp:SlideShowExtender ID="SlideShowExtender5" runat="server" SlideShowServiceMethod="GetSlides" TargetControlID="img" UseContextKey="True"></asp:SlideShowExtender> </asp:Panel>
To where I can add this GetSlides() static method in master page? Because it gives an runtime error always method is not available.
Saturday, April 12, 2014 7:40 PM
Answers
-
User-1818759697 posted
Hi,
You could add one new webservice page to your application and give name as Slideshow.asmx, then add the GetSlides method into the web services(.asmx) file:
[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; } }
For detailed information, you could refer to:
http://www.aspdotnet-suresh.com/2011/03/ajax-slideshowextender-control-sample.html
Regards
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, April 14, 2014 4:09 AM
All replies
-
User541108374 posted
Hi,
you can place it in code behind. For video material and samples about this particular control take a look at http://www.asp.net/ajaxlibrary/HOW%20TO%20Use%20the%20SlideShow%20Control.ashx.
Grz, Kris.
Monday, April 14, 2014 2:35 AM -
User-1818759697 posted
Hi,
You could add one new webservice page to your application and give name as Slideshow.asmx, then add the GetSlides method into the web services(.asmx) file:
[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; } }
For detailed information, you could refer to:
http://www.aspdotnet-suresh.com/2011/03/ajax-slideshowextender-control-sample.html
Regards
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, April 14, 2014 4:09 AM -
Monday, April 14, 2014 11:55 PM