Show a "thank you" page for only 15 seconds
After the user types in an application on a webpage - they click SUBMIT - we save the data.
We then go to a Thank You page.
This Thank You page has a button for "LOAD ANOTHER APPLICATION" that returns to the prior page.
I would like to make it so that after 15 seconds of being on the THANK YOU page it goes to the APPLICATION page automatically.
Is this possible?
Re: Show a "thank you" page for only 15 seconds
Hey,
You could do this in a couple ways.
1) A quick and dirty way - refresh tag in head element:
http://en.wikipedia.org/wiki/Meta_refresh
2) A more correct way, send Redirect Response to the page:
Code:
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","<your new url>");
}
</script>
Hope that helps!!
Gary
Re: Show a "thank you" page for only 15 seconds
How would the "more correct" way be done after a 15 second pause?
Re: Show a "thank you" page for only 15 seconds
Hey,
You could use a timer, but I tend to shy away from Timers in ASP.Net.
The other way would be to use a setTimeout on the Client and then do the redirect on the client, but then I tend to shy away from setTimeout as well.
That doesn't really help, does it :)
Gary
Re: Show a "thank you" page for only 15 seconds
You can put the asp.net timer and set the interval property appropriately. Then you can check IsPostBack=True on server side and Response.Redirect to the new page accordingly.
If for any reason you can't put the asp.net timer control, you can construct a javascript timer.
Here is a way how to do it.
(not tested code. may need tweaking)
Code:
<head>
<!-- head goes here -->
<script language="JavaScript" type="text/javascript">
var secs = 15;
var timer;
function SetTimer() {
if (secs <= 0) {
clearTimeout(timer);
document.form.whatever.submit();
}
else {
secs--;
timer = self.setTimeout("SetTimer()", 1000);
}
}
</script>
</head>
<body onload="SetTimer()">
<form id="whatever" method="post" runat="server">
<!-- Body goes here -->
</form>
</body>
</html>
This would postback automatically after 15 seconds have elapsed. On the server-side you can check IsPostBack=True on server side and Response.Redirect to the new page accordingly.
Re: Show a "thank you" page for only 15 seconds
Why does this client keep asking for things like this...
We already use JS for stuff - so I guess the JS timer makes sense.
Re: Show a "thank you" page for only 15 seconds
Code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript" language="javascript">
function callme()
{
exforsys = setTimeout("alert('Dude you are getting redirected to tatadocomo');window.location='http://create.tatadocomo.com'",5000);
}
</script>
</head>
<body onload="callme();">
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
i have tested this code...
hope this helps..
gary i'm big fan of yours..
your idea is good but we need to use timer
but this time i'm not impressed..
Re: Show a "thank you" page for only 15 seconds
How do I put that into a page with a master page?
Code:
<%@ Page Title="Vendor Thank You" Language="VB" MasterPageFile="~/StyleAndAuth.master" AutoEventWireup="false" CodeFile="FinishApp.aspx.vb" Inherits="Vendors_FinishApp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeaderPlaceHolder" Runat="Server">
<table width="1000">
<tr>
<td align="left" width="20%">
<asp:Label ID="HomeLbl" runat="server" ForeColor="Black" Text="Client Home"
Font-Size="Small"></asp:Label>
</td>
<td align="center" width="60%">
<asp:Label ID="WelcomeLbl" runat="server" ForeColor="Black"
Style="position: relative;" Text="Client Home" Font-Size="Small"></asp:Label>
</td>
<td align="right" width="20%" >
<asp:LoginStatus ID="LoginStatus1" runat="server"
LogoutPageUrl="~/Login.aspx" Font-Size="Small" Font-Underline="True"
ForeColor="Black" />
</td>
</tr>
</table>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="BodyPlaceHolder" Runat="Server">
<div style="text-align:center; width:984px;">
<!-- Project / File Info -->
<div align="left">
<div style="text-align:Left">
<b><br />
<asp:Label ID="Label15" runat="server" ForeColor="ForestGreen" Text="Vendor Application" Width="100%"></asp:Label><br />
</b>
</div>
</div>
<div style="background-color:#eeeeee; text-align:left; padding-left: 5px">
<div style="text-align:center; vertical-align:middle; width:100%; background-color:#eeeeee;" >
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<b>
Thank you for your Application!</b><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<b><asp:Button ID="SubmitProject" runat="server" Text="Begin New Application" Width="175px" Style="background-color:Lime"/></b>
<br />
<br />
</div>
Vendor Id: <asp:Label ID="VendorId" runat="server"></asp:Label>
<br />
</div>
</div>
</asp:Content>
Re: Show a "thank you" page for only 15 seconds
I think it won't matter. Just add that Javascript block at the end of the page.
Code:
<script language="JavaScript" type="text/javascript">
var secs = 15;
var timer;
function SetTimer() {
if (secs <= 0) {
clearTimeout(timer);
document.form.whatever.submit();
// or set window.location = "some url" if postback is not required.
}
else {
secs--;
timer = self.setTimeout("SetTimer()", 1000);
}
}
</script>
@dnanetwork: working too hard on client/server codes these days, I just forgot that we can simply redirect using javascript. :D
Re: Show a "thank you" page for only 15 seconds
Not allowed outside content panels error (or something like that).
I see from another page that there is a script manager - is that required for JS on pages with Master pages?
Re: Show a "thank you" page for only 15 seconds
okk I see. So the best way I see is to add a ContentPlaceHolder in your StyleAndAuth.master, somewhere inside the <head></head> tags.
So then in this page, you can put it inside that place holder, like you have done for these two.
Re: Show a "thank you" page for only 15 seconds
I was just starting to understand how that MP stuff is working. I had a web-coder over the summer research most of this and then implement it.
So - you are saying that I can add a content placeholder to the MASTER page and all existing pages that reference the MASTER - but do not invoke this new content placeholder - will still work??
Re: Show a "thank you" page for only 15 seconds
Yes, that's right.
You can add a content placeholder in the master page. So if you need to place something at that place on your page, you just put them in the appropriate <asp:Content></asp:Content> in your child pages. This is optional. If you do not place any of them in your child pages, they do not render (or render with whatever default you have placed in the master page if any).
Re: Show a "thank you" page for only 15 seconds
Hey,
Would another alternative not be to inject the JavaScript onto the page:
http://msdn.microsoft.com/en-us/library/btf44dc9.aspx
Gary