joe_pool_is
Contributor
Does anyone know how to make the form sleep in ASP.NET? I want the page to sleep for a bit before redirecting to another page.
Regards,
Joe
Regards,
Joe
Doesn't work. I got:kahlua001 said:i believe its system.thread.sleep(x)
where x is milliseconds
[/b]Line 132:
Line 133: public void GoHome(object sender, System.EventArgs e) {
[color=red]Line 134: system.thread.sleep(20000);[/color]
Line 135: Response.Redirect([url="http://www.google.com/"]http://www.google.com/[/url]);
Line 136: }
Looks like this makes everything sort of freeze up for a bit, which is not what we are trying to do.kahlua001 said:sorry, its
System.Threading.Thread.Sleep(x)
The problem is getting JS and ASP to talk to one another. Is it really possible?kahlua001 said:So when one panel becomes active, why cant you use the setTimeout function in JS to wait and then redirect? Was it not working for you before? Show us your code.
<%@ Page Language="c#" %>
<%@ import Namespace="System.Text" %>
<%@ import Namespace="System.IO" %>
<%@ import Namespace="System.Web.Mail" %>
<script runat="server">
public void OnClickSubmit (object sender, System.EventArgs e) {
string strUsername = "JonDoe"; // no, this is not my username
string strPassword = "123xxx"; // no, this is not my password
SmtpMail.SmtpServer = "smtp.mail.yahoo.com"; // Yahoo!'s $19/year service
MailMessage mail = new MailMessage();
mail.Subject = "New Email From Website";
mail.From = "\"" + Request.Form["txtName"] + "\" <" + Request.Form["txtEmail"] + ">";
mail.To = strMyEmailAddress;
mail.Body = Request.Form["txtMessage"];
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", strUsername);
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", strPassword);
SmtpMail.Send(mail);
lblResponse.Text = "<h3><center>Thank You!</center></h3>Your message has successfully been sent.<hr>";
MainPanel.Visible = false;
DonePanel.Visible = true;
}
</script>
<html>
<head><title>Mail Form</title></head>
<body>
<asp:panel id="MainPanel" runat="server" Width="100%">
<form id="Form1" method="post" runat="server">
<table width="100%"><tbody>
<tr><td align="middle" colspan="2"><h3>Email Form</h3></td></tr>
<tr>
<td align="right"><b>Name:</b></td>
<td align="left"><asp:textbox id="txtName" runat="server" /></td>
</tr>
<tr>
<td align="right"><b>Email:</b></td>
<td align="left"><asp:textbox id="txtEmail" runat="server" /></td>
</tr>
<tr>
<td align="middle" colspan="2"><b>Message:</b><br />
<asp:textbox id="txtMessage" runat="server" Rows="10" Columns="60" TextMode="MultiLine" /><br />
<asp:button id="submit" onclick="OnClickSubmit" runat="server" Text="Send" />
</td>
</tr>
</tbody></table>
</form>
<center>Click <a href="javascript:history.go(-1)">here</a> to go back.
</asp:panel>
<asp:panel id="DonePanel" runat="server" Width="100%" Visible="False">
<form id="Form2" runat="server">
<asp:Literal id="lblResponse" runat="server"></asp:Literal>
</form>
<center>Click <a href="javascript:history.go(-2)">here</a> to go back.</center>
</asp:panel>
</body>
</html>