Provide capability to start and stop image slideshow Part 136

Provide capability to start and stop image slideshow   Part 136



this part 136 of asp.net tutorial in this video we'll discuss providing the capability to start and stop the image slideshow that we have created in part 134 and 135 please watch these parts before proceeding with this video because we'll be working with the same example that we started in part 134 notice that at the moment the end-user doesn't have any capability to stop this slideshow that's already in progress now this is what we want to achieve we want to provide the user with in button control if the slideshow is not already in progress the text on the button control will say start slideshow once the user clicks on that button the slideshow should start and the text on the button control should immediately change to stop slideshow and then when the user clicks stop slideshow the slideshow that's in progress should stop immediately and the text on the button control should change back to start slideshow and this is very straightforward to achieve all you need to do is drag and drop your button control and double click on that to generate the even handler and then within the even handler you either have to enable or disable the timer to start or stop the slideshow so basically if you remember you know we are able to change the images that are displayed within the image control dynamically because the timer control raises this thick event now we have configured the interval for the timer control as 1000 milliseconds that's one second so every one second this timer control is raising the tick event and it pulls the page back to the server and upon post back within that tick event handler we have written code to change the image within the image control dynamically and now this timer control is capable of raising the deke event only if it is enable if you disable it it's not going to raise that tick event meaning it's not going to post the page back to the server in which case it's going to stop the slideshow so all you have to do is enable or disable the timer control but you'll have to check the state of the control before you do that okay so if the timer control is enabled then we know that this slideshow is already in progress and we want to stop the slideshow because the user has clicked on button so if the timer is enable and if the user has clicked on the button disable the timer which is going to stop the slideshow and since we have stopped the slideshow the text on the button control should say start slideshow and that's what we have it here okay if it is coming to else bar then we know the timer control is already disabled meaning the slideshow has already stopped and we need to enable you know the timer control for it to have to raise that tick event so we are enabling the timer control and then we are setting the text of the button control to stop slideshow okay let's look at this in action so let's go to default or aspx include to HTML brakes there drag and drop a button control and initially when the waveform first loads you know the slideshow will be in progress so we want the text on the button control to be something like stop slideshow and then let's flip this waveform to the design mode double click that regenerate the event handler and then within the even handler if the timer control is already enable then in that case disable the timer control and to do that all we are going to do is set enable property to false and then since you have disabled the timer control the text on the button control needs to say start slideshow on the other hand if the timer control is already disabled then we need to enable that and the text on the button control should say stop slideshow so these changes let's go ahead and run this and now the end user should have the capability to start and stop the slideshow on demand so the slideshow is in progress we are at number five six click stop slideshow look at that it stopped at image six now once they click on start slideshow it should resume at image seven there we go so I can stop it I can start it again okay now at the moment there are two problems with this code if we want to add a new image to the slideshow then we will have to modify the application code because if you remember you know we have hard-coded you know I to eight here because we have maximum of eight images here you know once it reaches number eight image number eight we want to reset it at one and start all over again that's why we have hard-coded it at eight now let's say if I want to add a new image to the slideshow you know I'll have to change this application code all I have to do is change it to nine it's going to work but then you know while this application code change is not that complicated but it is still going to require you know testing deployment you know to the build and deployment to the production server which is obviously going to contain consume okay so I mean anytime you want to add an image to the existing slideshow it should be as simple as a configuration change it shouldn't require the application code to be built and deployed again okay so that's the first problem you know adding an image to the slideshow is causing your application code to be modified because we haven't written it in the most efficient way okay and another problem is the new image has to be named in a specific way you know if you remember these image names were something completely different but we have changed their names to one two three and four okay so the new image if it has some some other name like XYZ jpg we'll have to change it to nine dot J PJ okay so obviously you know that's a disadvantage because if we want to remember those image names for some other purpose you know we don't have that right now we don't have those images names at the moment okay so let's see how to fix both of these issues in our next video on this slide you can find resources for asp.net c-sharp and sequence of interview questions thank you for listening have a great day

8 thoughts on “Provide capability to start and stop image slideshow Part 136

  • June 2, 2019 at 11:37 am
    Permalink

    Thanks You sir. You are so generous

    Reply
  • June 2, 2019 at 11:37 am
    Permalink

    Hello Mr. Venkat,
    Excellent video, can we make images fade away instead of changing so quickly?

    Reply
  • June 2, 2019 at 11:37 am
    Permalink

    Thank you very much for taking time to give feedback. For email alerts, when new videos are uploaded, please subscribe to my channel. In the description of this video, I have included the link for ASP .NET, C#, and SQL Server playlists. All the videos are arranged in logical sequence in these playlists, which could be useful to you. Please share the link with your friends who you think would also benefit from them. If you like these videos, please click on the THUMBS UP button below the video.

    Reply
  • June 2, 2019 at 11:37 am
    Permalink

    Hi Praveen, Sure, I will record and upload videos on LINQ and WCF as soon as I can.

    Reply
  • June 2, 2019 at 11:37 am
    Permalink

    Thank you very much for taking time to give feedback. For email alerts, when new videos are uploaded, please subscribe to my channel. In the description of this video, I have included the link for ASP .NET, C#, and SQL Server playlists. All the videos are arranged in logical sequence in these playlists, which could be useful to you. Please share the link with your friends who you think would also benefit from them. If you like these videos, please click on the THUMBS UP button below the video.

    Reply
  • June 2, 2019 at 11:37 am
    Permalink

    Thank you so much sir for providing us very helpful tutorial on different topics. Your job is really incredible. It helps me alot to understand asp.net as well as other .net topics . I have seen all of your video series. Can you record a video series on LINQ and WCF? Once again thanks. May God bless you a long healthy life.

    Reply
  • June 2, 2019 at 11:37 am
    Permalink

    Hi Sir Thanks for sharing knowledge, can u make an video on MASTER PAGES in asp.net. Thanks u sir once again.

    Reply
  • June 2, 2019 at 11:37 am
    Permalink

    Thank you Sir, 4r all those tutorials I Have Seen all Of Them, All r great. thanx again…………

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *