在ASP.NET中使用JavaScript显示确认对话框 [英] Display confirmation box in ASP.NET using JavaScript

查看:130
本文介绍了在ASP.NET中使用JavaScript显示确认对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要显示确认框你确定要继续吗?如果是我需要的ASP.NET文本框的值被清除出去。否则它不应该被清除。


解决方案

 函数doConfirm(){
  如果(确认(你确定要继续吗?)){
     VAR mytxtbox =的document.getElementById('<%= myAspTextBox.ClientID%GT;');
     mytxtbox.value ='';
  }}

注意myAspTextBox指的是ASP的名称:TextBox控件的ID属性

 < ASP:文本ID =myAspTextBox=服务器的OnClientClick =JavaScript的:doConfirm();

希望这有助于

I need to show the confirm box "Are you sure You Want To continue?" If "Yes" I need the ASP.NET textbox value to be cleared out. Otherwise it should not be cleared.

解决方案

function doConfirm(){
  if (confirm("Are you sure you want to continue?")){
     var mytxtbox = document.getElementById('<% =myAspTextBox.ClientID %>');
     mytxtbox.value = '';
  }    

}

Note the myAspTextBox refers to the name of the asp:textbox controls ID property

<asp:textbox ID="myAspTextBox" runat="server" OnClientClick="javascript:doConfirm();"

Hope this helps

这篇关于在ASP.NET中使用JavaScript显示确认对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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