简体   繁体   English

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

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

How can I clear my textboxes after I click on cancel button in confirm message box. 单击确认消息框中的取消按钮后,如何清除文本框。 My message box script is,(In web application). 我的消息框脚本是(在Web应用程序中)。 If we cannot perform with this script message, Refer me another one. 如果我们无法使用此脚本消息执行操作,请另外推荐我。

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

it returns true or false on the basis of what button you have clicked.. 它会根据您单击的按钮返回true or false

better to write a separate function and include it in your JavaScript file and call like the above way you are doing.. 最好编写一个单独的函数并将其包含在您的JavaScript文件中,然后像上述操作一样进行调用。

else you have to write the whole code inline, but looks messy.. 否则,您必须内联编写整个代码,但是看起来很乱。

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