如何显示浏览器消息和消息点击事件需要handel代码? [英] How to show browser message and on message click event need to handel the code?

查看:69
本文介绍了如何显示浏览器消息和消息点击事件需要handel代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在asp.net页面中输入以下提到的代码BROWSER  仅显示消息但是 if 我想添加我创建的按钮 - > OK和CANCEL以及OK按钮我必须编写一些代码吗? 

if (isUpdateXMLReportDataSuccess == true
{
Response.Write( @ < SCRIPT LANGUAGE =JavaScript> alert(' + 错误创建。 + ')< / SCRIPT>);
Response.Redirect( ./ ManageDefects.aspx);
}
else
{Response.Write( @ < span class =code-string>< SCRIPT LANGUAGE =JavaScript> alert(' + 错误未成功创建。 + ')< / SCRIPT>< /跨度>); return ;}


此外,我想在 > my case if isUpdateXMLReportDataSuccess TRUE所以根据代码浏览器首先应该显示消息,即 Bug创建成功。然后它应该重新直接重定向( ./ ManageDefects.aspx);

我的 case 它转到`Response.Write( @ < SCRIPT LANGUAGE =JavaScript> alert(' + 错误创建成功。 + )< / SCRIPT>);`但不在BROWSER上显示消息并直接转到Response.Redirect( ./ ManageDefects.aspx);


它不显示浏览器消息。





我尝试过:



在我的情况下,它转到`Response.Write(@< SCRIPT LANGUAGE =JavaScript> alert('+ Bug已成功创建。+')< / SCRIPT>);`但不在BROWSER上显示消息并直接转到Response.Redirect(./ ManageDefects.aspx);





它不显示浏览器消息

解决方案

调用Response.Redirect基本上是说扔掉这个页面,直接进入这个。这就是系统所做的。它会抛弃您为页面构建的所有HTML(而不是在完成组装后将其发送到浏览器)并立即加载新页面。这就像开始开车去商店,决定去中途看朋友。你所驾驶的距离被忽略,并立即启动你朋友家的新航线。

如果你想要一个警报,不要打电话给Response.Redirect!






我得到了上述问题的解决方案



而不是使用 代码。 
Response.Write( @ < SCRIPT LANGUAGE =JavaScript> alert(' + 错误创建。 + ')< / SCRIPT>);
Response.Redirect( ./ ManageDefects.aspx);



使用一个。
ScriptManager.RegisterStartupScript( this typeof string ), redirect alert('message goes here'); window.location =' + Request.ApplicationPath + / foldername / pagename.aspx'; true );


In asp.net page by entering the below mentioned code BROWSER is only showing the message but what if i want to ADD Buttons which i created like --> OK and CANCEL and on OK button i have to write some code?     

    if (isUpdateXMLReportDataSuccess == true)
        {        
            Response.Write(@"<SCRIPT LANGUAGE=""JavaScript"">alert('" + "Bug created successfully." + "')</SCRIPT>");
    Response.Redirect("./ManageDefects.aspx");   
        }
        else
        {Response.Write(@"<SCRIPT LANGUAGE=""JavaScript"">alert('" + "Bug not created successfully." + "')</SCRIPT>"); return;}


Also here i want to ask that in my case if the isUpdateXMLReportDataSuccess  is TRUE So according to code browser first should need to showing the message i.e "Bug created successfully." and then it should  Re-directly Redirect("./ManageDefects.aspx");

But in my case it goes to `Response.Write(@"<SCRIPT LANGUAGE=""JavaScript"">alert('" + "Bug created successfully." + "')</SCRIPT>");` but not showing the message on BROWSER and directly goes to Response.Redirect("./ManageDefects.aspx");


ITS NOT SHOWING THE BROWSER MESSAGE.



What I have tried:

In my case it goes to `Response.Write(@"<SCRIPT LANGUAGE=""JavaScript"">alert('" + "Bug created successfully." + "')</SCRIPT>");` but not showing the message on BROWSER and directly goes to Response.Redirect("./ManageDefects.aspx");


ITS NOT SHOWING THE BROWSER MESSAGE

解决方案

Calling Response.Redirect is basically saying "throw away this page, and go directly to this one". So that's what the system does. It throws away all the HTML you have built for the page (instead of sending it to the browser when you have finished assembling it) and immediately loads a new page. It's like starting to drive to the shops and deciding half way to go see a friend instead. The distance you have driven is ignored, and a new course to your friend's house is immediately started.
If you want an alert, don't call Response.Redirect!


Hi,

I got the solution for above issue

Instead of using this code.
 Response.Write(@"<SCRIPT LANGUAGE=""JavaScript"">alert('" + "Bug created successfully." + "')</SCRIPT>");
Response.Redirect("./ManageDefects.aspx"); 



 Use this one.
    ScriptManager.RegisterStartupScript(this, typeof(string), "redirect", "alert('message goes here'); window.location='" + Request.ApplicationPath + "/foldername/pagename.aspx';", true);


这篇关于如何显示浏览器消息和消息点击事件需要handel代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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