繁体   English   中英

单击确认消息框中的取消按钮后如何清除文本框?

[英]How to clear textbox after click of cancel button in confirm message box?

单击确认消息框中的取消按钮后,如何清除文本框。 我的消息框脚本是(在Web应用程序中)。 如果我们无法使用此脚本消息执行操作,请另外推荐我。

 ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "confirm", "confirm('Do you want to delete it ..!!');", true);
confirm('Do you want to delete it ..!!')

它会根据您单击的按钮返回true or false

最好编写一个单独的函数并将其包含在您的JavaScript文件中,然后像上述操作一样进行调用。

否则,您必须内联编写整个代码,但是看起来很乱。

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "confirm", "" +
    "document.body.onload = function(){"+
      "if(confirm('Do you want to delete it ..!!')==false)" +
        "{" +
           "document.getElementById('myTextBox').value='';" +
        "}"+
      "}", true);
   ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "confirm", "confirm('Do you want to delete it ..!!');", true) ? txtDate.text = string.Empty : txtdate1.text = string.Empty;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM