How do you do that? Like if a user resets their password or something, it will say something like "Password has been reset. You will now be redirected to blah blah blah. Click here if you don't want to wait."
How can you set it to redirect after a certain amount of time?
You can put the client side script anywhere in the body as well as in the header so you can just put the <script> inside your contentplaceholder like such:
<asp:Content ID="Content2" ContentPlaceHolderID="main" Runat="Server">
your other content here
<script type="text/javascript">
function delayRedirect(url)
{
var Timeout = setTimeout("window.location='" + url + "'",10000);
}
</script>
</asp:Content>
And then you can call this from the code behind if you want like this:
ClientScript.RegisterStartupScript(Page.GetType, "Delay then redirect", "<script type=text/javascript>delayRedirect('http://divtag.com');</script>")
Here is the code for both the aspx and the aspx.vb from a working example:
<asp:Content ID="Content2" ContentPlaceHolderID="main" Runat="Server">
your other content here
<script type="text/javascript">
function delayRedirect(url)
{
var Timeout = setTimeout("window.location='" + url + "'",10000);
}
</script>
</asp:Content>
aspx.vb
Partial Class test
Inherits System.Web.UI.Page
Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs)
If Not IsPostBack Then
ClientScript.RegisterStartupScript(Page.GetType, "Delay then redirect", "<script type=text/javascript>delayRedirect('http://divtag.com');</script>")
End If
End Sub
End Class
If you want to add meta-tags, you could put a content placeholder in your header section of your master page. Then you can load this with "header" elements in your content...
hth
Kelsey Thornton
Don't forget - Mark the post which answered your question with "Answer", then that user will get some kudos, and your post will be marked as "Answered" for future readers!
Apples
Member
75 Points
452 Posts
Redirect to a page after 10 seconds
May 08, 2008 04:55 PM|LINK
How do you do that? Like if a user resets their password or something, it will say something like "Password has been reset. You will now be redirected to blah blah blah. Click here if you don't want to wait."
How can you set it to redirect after a certain amount of time?
Jeev
All-Star
24182 Points
3719 Posts
Re: Redirect to a page after 10 seconds
May 08, 2008 05:06 PM|LINK
<META HTTP-EQUIV="REFRESH" CONTENT="10;URL=newpage.aspx"> Put this meta tag in the header and it will redirect after 10 sec to newpage.aspx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you get the answer to your question, please mark it as the answer.
timwilson
Member
134 Points
123 Posts
Re: Redirect to a page after 10 seconds
May 08, 2008 05:13 PM|LINK
That would work fine, you could also do it in javascript so you could have a little more control over the url you were directing to etc.
<script>
delayRedirect('http://divtag.com');
function delayRedirect(url)
{
var Timeout = setTimeout("window.location='" + url + "'",10000);
}
</script>
Apples
Member
75 Points
452 Posts
Re: Redirect to a page after 10 seconds
May 08, 2008 06:00 PM|LINK
I need to do this in a content page, how can I add scripts or meta tags to it?
timwilson
Member
134 Points
123 Posts
Re: Redirect to a page after 10 seconds
May 08, 2008 07:02 PM|LINK
You can put the client side script anywhere in the body as well as in the header so you can just put the <script> inside your contentplaceholder like such:
<asp:Content ID="Content2" ContentPlaceHolderID="main" Runat="Server">
your other content here
<script type="text/javascript">
function delayRedirect(url)
{
var Timeout = setTimeout("window.location='" + url + "'",10000);
}
</script>
</asp:Content>
And then you can call this from the code behind if you want like this:
ClientScript.RegisterStartupScript(Page.GetType, "Delay then redirect", "<script type=text/javascript>delayRedirect('http://divtag.com');</script>")
Here is the code for both the aspx and the aspx.vb from a working example:
aspx:
<%@ Page Language="VB" MasterPageFile="~/Default.master" AutoEventWireup="true" CodeFile="test.aspx.vb" Inherits="test" title="Untitled Page" %>
<asp:Content ID="Content2" ContentPlaceHolderID="main" Runat="Server">
your other content here
<script type="text/javascript">
function delayRedirect(url)
{
var Timeout = setTimeout("window.location='" + url + "'",10000);
}
</script>
</asp:Content>
aspx.vb
Partial Class test
Inherits System.Web.UI.Page
Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs)
If Not IsPostBack Then
ClientScript.RegisterStartupScript(Page.GetType, "Delay then redirect", "<script type=text/javascript>delayRedirect('http://divtag.com');</script>")
End If
End Sub
End Class
KelseyThornt...
Participant
904 Points
236 Posts
Re: Redirect to a page after 10 seconds
May 08, 2008 07:43 PM|LINK
If you want to add meta-tags, you could put a content placeholder in your header section of your master page. Then you can load this with "header" elements in your content...
hth
Don't forget - Mark the post which answered your question with "Answer", then that user will get some kudos, and your post will be marked as "Answered" for future readers!
(VB code examples preferred)