javascript确认问题 [英] javascript confirmation problem

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

问题描述

大家好,

i在asp.net上有一个弹出确认窗口。

但不幸的是我的客户端javascript代码执行相同的功能。

这意味着我实际上是这样做的,这个号码是否要删除



如果我点击确定按钮然后这个号码已被删除,如果我点击取消按钮,那么这个号码也已被删除。



所以这是我的问题。

请你看看下面的代码,



< script type =text / javascript>



函数DeleteCli(id)

{

// window.open(JHProducts.asp?ID =+ id);

var dlt = confirm(你确定要删除这个号吗?+ id,null,status = yes,resizable = no,left = 350,top = 250,width = 350,身高= 250);



}

< / script>



< asp:Button ID =LinkBut​​ton1runat =serverBorderColor =WhiteBorderStyle =noneCausesValidation =falseCommandName =delete Text =删除OnClientClick ='<%#String.Format(javascript:DeleteCli({0});,Eval(CLI))%>'/>





问候,

stellus。

hi all,
i have a pop-up confirmation window on asp.net.
but unfortunately my client side javascript code do the same function.
which means i actually do that, "whether this number want to delete or not"

if i click ok button then the number has been deleted and
if i click cancel button then the number also has been deleted.

so this is my problem.
please have you look at the code below,

<script type="text/javascript">

function DeleteCli(id)
{
// window.open("JHProducts.asp?ID=" + id );
var dlt = confirm("Are you sure want to delete this number?"+ id,null,"status=yes,resizable=no,left=350,top=250,width=350,height=250");

}
</script>

<asp:Button ID="LinkButton1" runat="server" BorderColor="White" BorderStyle="none" CausesValidation="false" CommandName="delete" Text ="Delete" OnClientClick='<%# String.Format("javascript:DeleteCli(""{0}"");", Eval("CLI"))%>'/>


regards,
stellus.

推荐答案

返回确认值,如果取消按钮点击它将阻止服务器调用

return the value of confirm and it will prevent the server call if cancel button click
function DeleteCli(id) 
{
  return confirm("Are you sure want to delete this number?"+ id,null,"status=yes,resizable=no,left=350,top=250,width=350,height=250");
}


如果用户选择否,您需要返回false或者返回dlt作为函数的结果以防止进一步执行(回发)。



您还需要将您的asp:按钮更改为:

You need to return false or rather return dlt as result of your function to prevent further execution (postback) if the user selects No.

You'll also need to change your asp:Button to:
<asp:button id="LinkButton1" runat="server" bordercolor="White" borderstyle="none" causesvalidation="false" commandname="delete" text="Delete" onclientclick="<%# String.Format("javascript: <b><u>return</u></b> DeleteCli(""{0}"");", Eval("CLI"))%>" xmlns:asp="#unknown" />







如果这有帮助,请花时间接受解决方案。谢谢。




If this helps please take time to accept the solution. Thank you.


这篇关于javascript确认问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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