弹出消息有是和没有按钮重定向到不同的页面 [英] Popup message to have yes and no buttons to redirect to different pages

查看:65
本文介绍了弹出消息有是和没有按钮重定向到不同的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个允许用户输入数据的网络表单。当用户单击保存按钮时,会弹出一条消息,要求用户在输入更多数据时单击确定,如果输入完数据则单击否。如何在弹出消息上获得是和否按钮?



这是我现在的代码:

I have a web form that lets a user enters data. When the user clicks the save button there is a message that pops up and asks the user to click ok if they have more data to enter or click no if they are finished entering data. How can I get the yes and no buttons on the popup message?

Here is the code I have now:

ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Saved the Cohort. If you have Additional Cohorts, Please Click the OK Button to Enter another Cohort. If you are finished entering Cohorts Click the Menu Button at the bottom of the screen');location.href='Page5.aspx';", true);





此代码有效,但我需要将yes按钮重定向到同一页面,而无按钮重定向到另一个页面。



我有这个代码有确定和取消按钮但按钮由于某种原因不起作用。这是我的代码:



This code works but I need it to have the yes button to redirect to same page and the no button to redirect to another page.

I have this code that has the Ok and Cancel button but the buttons don't work for some reason. Here is my code:

ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "var r = confirm('Data updated successfully. You will now redirected to search page.'); if (r == true) var str= 'Login.aspx'; location.href = 'Gradrate.aspx' ;", true);

推荐答案

如果您可以使用标有确定和取消的按钮,那么您可以使用 确认方法 [ ^ ]。

If you can live with the buttons being labelled "OK" and "Cancel", then you can use the confirm method[^].
if(confirm("...")){ 
    /* user clicked "OK" */ 
    location.href = "OkPage.aspx";
} 
else { 
    /* User clicked "Cancel" */
    location.href = "CancelPage.aspx";
}



如果你需要按钮上的自定义文字,那么你需要一个自定义的Javascript对话框。 jQuery UI [ ^ ]是一个很好的起点。


If you need custom text on the buttons, then you'll need a custom Javascript dialog. jQuery UI[^] is a good place to start.


检查如何显示消息并重定向到ASP.NET中的其他页面 [ ^ ]


这篇关于弹出消息有是和没有按钮重定向到不同的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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