我在Aspx的按钮中使用返回确认,但我需要转到其他页面我单击确定 [英] I Used Return Confirm In The Button In Aspx But I Need Go To Other Pages I Click In Ok
本文介绍了我在Aspx的按钮中使用返回确认,但我需要转到其他页面我单击确定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的按钮代码
this is my button code
<asp:Button ID="Button1" runat="server" PostBackUrl="~/Transferencia.aspx"
Text="aceptar" onclick="Button1_Click"
onclientclick="confirm ('Do you want to cancel ?');" />
但是我说好的,不要去transferencias.aspx我需要做什么。
感谢您的帮助。
but i say ok and don't go to transferencias.aspx what i need to do.
thank for help me.
推荐答案
不要添加p ostback网址。 insted写一个javascript函数,如果确认可以重定向到其他页面。
do not add postback url. insted write a javascript function and if confirm is ok redirect to other page .
function movetonextpage()
{
if(confirm(are you sure you want to cancel?))
{
window.location = 'your page name';
}
else
{
return false;
}
}
在按钮客户端点击上调用此功能。
call this function on the button client click.
当用户未确认时,请尝试返回false
。
Try returningfalse
when user does not confirm.
<asp:Button ID="Button1"
runat="server"
PostBackUrl="~/Transferencia.aspx"
Text="aceptar"
OnClick="Button1_Click"
OnClientClick="if ( ! UserConfirmation()) return false;" />
使用以下 JavaScript
。
Use the following JavaScript
.
function UserConfirmation() {
return confirm("Do you want to cancel ?");
}
因此,当用户按 cancel
时,该函数将返回 false
到 OnClienClickEvent
并且满足if条件。
因此,它再次在事件中执行 return false;
。所以, PostBack
没有发生。
So, when user presses cancel
, the function will return false
to OnClienClickEvent
and satisfies the if condition.
So, again it executes return false;
inside the Event. So, PostBack
does not happen.
试试这个..
try this..
<asp:Button ID="Button1" runat="server"
Text="aceptar" onclick="Button1_Click"
onclientclick="!confirm ('Do you want to cancel ?');" />
这篇关于我在Aspx的按钮中使用返回确认,但我需要转到其他页面我单击确定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文