androidiscool Posted March 6, 2017 Share Posted March 6, 2017 I coded it and it all works except for unload. It only displays the 3 dots and no pictures. If you click on a dot then it all works. I use a master page and code behind in asp.net c#. Anyone know how to call the function in code behind default.aspx.cs to display a pic when web site is opened? You can see site which is under construction http://www.sueandpatphoto.com Link to comment Share on other sites More sharing options...
dsonesuk Posted March 6, 2017 Share Posted March 6, 2017 A page loads from top to bottom, your slideshow JavaScript is run before the html and references to slideshow classes have been rendered or exist, so its attempt to show first image with var slideIndex = 1; showSlides(slideIndex);Will fail because of this. When you click a dot, because everything is fully rendered, then it functions correctly. That is why you will find that this code is placed AFTER the slideshow. Link to comment Share on other sites More sharing options...
androidiscool Posted March 7, 2017 Author Share Posted March 7, 2017 Thanks but I am not clear how to fix. Link to comment Share on other sites More sharing options...
dsonesuk Posted March 7, 2017 Share Posted March 7, 2017 (edited) A page loads from top to bottom, your slideshow JavaScript is run before the html and references to slideshow classes have been rendered or exist, so its attempt to show first image with var slideIndex = 1; showSlides(slideIndex); Will fail because of this. When you click a dot, because everything is fully rendered, then it functions correctly. That is why you will find that this code is placed AFTER the slideshow. Pretty obvious in it? place link or JavaScript code related to slideshow below html code related to slideshow or place your js code within window.onload=function(){ ///slideshow code here } You should now days, place links or inline JavaScript code just before </bod> tag, this helps load page faster by loading html and css first, then JavaScript coding. Edited March 7, 2017 by dsonesuk Link to comment Share on other sites More sharing options...
androidiscool Posted March 7, 2017 Author Share Posted March 7, 2017 Thanks I will try Link to comment Share on other sites More sharing options...
androidiscool Posted March 7, 2017 Author Share Posted March 7, 2017 OK now it works. thanks for your help. However I had to add the link to the master page before the </body> as you said. But when I tried to remove it from default.aspx I just got a blank page. So it has to be in both places. Dont understand why but glad it works. thanks again. Link to comment Share on other sites More sharing options...
dsonesuk Posted March 7, 2017 Share Posted March 7, 2017 That is impractical, you should create an area for this purpose in the master template page or on the very bottom of slideshow content page that requires it. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now