Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 09, 2012 06:49 AM by Allen Li - MSFT
Member
7 Points
8 Posts
May 03, 2012 08:53 PM|LINK
Newbie here....I have seen some sites which change content within a master page every few seconds. How can I accomplish that?
Thanks,
Dinesh.
Star
10411 Points
1196 Posts
May 07, 2012 07:03 AM|LINK
Hi, you can use jQuery to achieve this, for example:
<html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $(document).ready(function () { $('.advertise div:gt(0)').hide(); setInterval(function () { $('.advertise :first-child').fadeOut(0) .next('div').fadeIn(1000) .end().appendTo('.advertise'); }, 2000); }); </script> </head> <body> <form id="form1" runat="server"> <div> <div class="advertise"> <div>This div 0</div> <div>This div 1</div> <div>This div 2</div> <div>This div 3</div> </div> </div> </form> </body> </html>
May 07, 2012 07:27 PM|LINK
This works good when the contents in the div are text. When I added images, the transition is not smooth. Sometimes transition does not happen. Is there any setting which I should change for images?
May 08, 2012 07:53 AM|LINK
Hi, you can modify my previous codes as following:
<html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $(document).ready(function () { $('.advertise div:gt(0)').hide(); setInterval(function () { $('.advertise div:first-child').fadeOut(0) .next('div').fadeIn(1000) .end().appendTo('.advertise'); }, 2000); }); </script> </head> <body> <form id="form1" runat="server"> <div> <div class="advertise"> <div>This div 0<img src="0.jpg" /></div> <div>This div 1<img src="1.jpg" /></div> <div>This div 2<img src="2.jpg" /></div> </div> </div> </form> </body> </html>
May 08, 2012 01:38 PM|LINK
It works fine when only text is there. Below is what I get when I add images:
AWP.png shows up first.
Then Logo.jpg shows up.
Then both show up together.
Then nothing comes up.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" MasterPageFile="MasterPage.master" %> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="ContentPlaceHolderMain"> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $(document).ready(function () { $('.advertise div:gt(0)').hide(); setInterval(function () { $('.advertise :first-child').fadeOut(0) .next('div').fadeIn(1000) .end().appendTo('.advertise'); }, 2000); }); </script> <div> <div class="advertise"> <div> <img alt="" src="Images/AWP.png" /> </div> <div> <img alt="" src="Images/Logo.jpg" /> </div> </div> </div> </asp:Content>
May 09, 2012 06:49 AM|LINK
Hi, please change the following codes:
thonipad $('.advertise :first-child').fadeOut(0)
$('.advertise :first-child').fadeOut(0)
$('.advertise div:first-child').fadeOut(0)
thonipad
Member
7 Points
8 Posts
Dynamically change content
May 03, 2012 08:53 PM|LINK
Newbie here....I have seen some sites which change content within a master page every few seconds. How can I accomplish that?
Thanks,
Dinesh.
Allen Li - M...
Star
10411 Points
1196 Posts
Re: Dynamically change content
May 07, 2012 07:03 AM|LINK
Hi, you can use jQuery to achieve this, for example:
<html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $(document).ready(function () { $('.advertise div:gt(0)').hide(); setInterval(function () { $('.advertise :first-child').fadeOut(0) .next('div').fadeIn(1000) .end().appendTo('.advertise'); }, 2000); }); </script> </head> <body> <form id="form1" runat="server"> <div> <div class="advertise"> <div>This div 0</div> <div>This div 1</div> <div>This div 2</div> <div>This div 3</div> </div> </div> </form> </body> </html>If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework
thonipad
Member
7 Points
8 Posts
Re: Dynamically change content
May 07, 2012 07:27 PM|LINK
This works good when the contents in the div are text. When I added images, the transition is not smooth. Sometimes transition does not happen. Is there any setting which I should change for images?
Thanks,
Dinesh.
Allen Li - M...
Star
10411 Points
1196 Posts
Re: Dynamically change content
May 08, 2012 07:53 AM|LINK
Hi, you can modify my previous codes as following:
<html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $(document).ready(function () { $('.advertise div:gt(0)').hide(); setInterval(function () { $('.advertise div:first-child').fadeOut(0) .next('div').fadeIn(1000) .end().appendTo('.advertise'); }, 2000); }); </script> </head> <body> <form id="form1" runat="server"> <div> <div class="advertise"> <div>This div 0<img src="0.jpg" /></div> <div>This div 1<img src="1.jpg" /></div> <div>This div 2<img src="2.jpg" /></div> </div> </div> </form> </body> </html>If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework
thonipad
Member
7 Points
8 Posts
Re: Dynamically change content
May 08, 2012 01:38 PM|LINK
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" MasterPageFile="MasterPage.master" %> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="ContentPlaceHolderMain"> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $(document).ready(function () { $('.advertise div:gt(0)').hide(); setInterval(function () { $('.advertise :first-child').fadeOut(0) .next('div').fadeIn(1000) .end().appendTo('.advertise'); }, 2000); }); </script> <div> <div class="advertise"> <div> <img alt="" src="Images/AWP.png" /> </div> <div> <img alt="" src="Images/Logo.jpg" /> </div> </div> </div> </asp:Content>Allen Li - M...
Star
10411 Points
1196 Posts
Re: Dynamically change content
May 09, 2012 06:49 AM|LINK
Hi, please change the following codes:
as:$('.advertise div:first-child').fadeOut(0)If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework