使网页等待 [英] making the web page to wait

查看:57
本文介绍了使网页等待的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮助我如何让网页等待吗?.

首先应显示警报,然后在显示警报后必须重定向页面..

现在它不显示警报了.直接将其重定向到另一个页面.

我正在使用以下代码..:

在C#中

Can anybody help me how to make the web page to wait..?

First the alert should be displayed then after displaying the alert the page must be redirected..

Now it is not displaying alert..Directly it will redirect to another page..

I am using the following code..:

in C#

private void MessageBox(string msg)
{
    Label lbl = new Label();
    lbl.Text = "<script language=''javascript''>" + Environment.NewLine + "window.alert(''" + msg + "'')</script>";
    Page.Controls.Add(lbl);
}

protected void Button1_Click(object sender, EventArgs e)
{
    MessageBox(theTextBox.Text);
    Response.Redirect("Default2.aspx");
}



请帮我..

再次感谢...
卡兰

[edit]已添加代码块-OriginalGriff [/edit]



Plz help me..

Thanks again...
Karan

[edit]Code block added - OriginalGriff[/edit]

推荐答案

不,那是行不通的. Response.Redirect立即用新页面替换到目前为止已写入页面的所有数据.
尝试以下方法:
No, that won''t work. The Response.Redirect immediately replaces all the data written to the page so far with the new page.
Try this instead:
Response.Write("<script>alert(''Hello'');window.location = ''http://www.google.co.uk''</script>");



[edit]由于键盘上的猫声造成的打字错误...-OriginalGriff [/edit]



[edit]Typos due to cat on keyboard... - OriginalGriff[/edit]


private void MessageBox(string msg)
    {
       
       string script = "<script type=\"text/javascript\">alert(msg);</script>";
   ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script);

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        MessageBox(theTextBox.Text);
        Response.Redirect("Default2.aspx");
    }



如果我误解了您的问题,请随时纠正我.
希望以上信息对您有所帮助.如果您还有其他顾虑,请告诉我.



If i misunderstand your question, please feel free to correct me.
I hope the above information will be helpful. If you have more concerns, please let me know.


这篇关于使网页等待的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆