I have mad a simple count down with a timer and a postbacktrigger. In tick event i have a switch case and in the end i want to set the whole page black but i cant get it to work. Code:
You've set the timer as an async trigger. So the only thing that will get updated is the content of the updatepanel. To confirm that, remove the timer as a async trigger and test.
Ollza
Member
572 Points
304 Posts
Set background color
Nov 28, 2011 11:26 AM|LINK
Hi,
I have mad a simple count down with a timer and a postbacktrigger. In tick event i have a switch case and in the end i want to set the whole page black but i cant get it to work. Code:
aspx and .cs:
<body id="bodytag" runat="server"> <form id="form1" runat="server" > <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:Timer ID="tTicker" runat="server" Interval="1000" OnTick="tTicker_Tick"> </asp:Timer> <asp:UpdatePanel ID="upTimer" UpdateMode="Conditional" runat="server"> <Triggers> <asp:AsyncPostBackTrigger ControlID="tTicker" EventName="Tick" /> </Triggers> <ContentTemplate> <asp:Image ID="imgNumber" runat="server" ImageUrl="~/img/0.JPG" Height="200px" Width="200px" /> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body> protected void tTicker_Tick(object sender, EventArgs e) { if (imgNumber.ImageUrl != null) { string key = imgNumber.ImageUrl.ToString(); switch (key) { case "~/img/0.JPG": imgNumber.ImageUrl = "~/img/1.JPG"; break; case "~/img/1.JPG": imgNumber.ImageUrl = "~/img/2.JPG"; break; case "~/img/2.JPG": imgNumber.ImageUrl = "~/img/3.JPG"; break; case "~/img/3.JPG": form1.Attributes.CssStyle.Add("BACKGROUND-COLOR", "#000000"); bodytag.Attributes.CssStyle.Add("BACKGROUND-COLOR", "#000000"); break; } } }MetalAsp.Net
All-Star
112752 Points
18373 Posts
Moderator
Re: Set background color
Nov 28, 2011 12:06 PM|LINK
You've set the timer as an async trigger. So the only thing that will get updated is the content of the updatepanel. To confirm that, remove the timer as a async trigger and test.
Ollza
Member
572 Points
304 Posts
Re: Set background color
Nov 28, 2011 01:48 PM|LINK
Yes that worked fine. Is it possible to acchive with a async trigger? A panel within the update panale that covers the whole page?