JS script

function ConfirmMe()
{
   return confirm("Do you want to proceed?");
}

ASPX

<asp:TextBox id="txtName" runat="server"/>
<asp:Button id="btnSubmit" OnClientClick="return ConfirmMe()" Text="Submit" runat="server"/>

Well, that is pretty straightforward. BUT, it goes weird when you have a validator control (eg. RequiredFieldValidator) that is used to validate the "txtName" textbox server control. For instance,

<asp:TextBox id="txtName" runat="server"/>

<asp:RequiredFieldValidator id="rq1" ControlToValidate="txtName" ErrorMessage="Name cannot be blank" Display="Dynamic" runat="server"/>

<asp:Button id="btnSubmit" OnClientClick="return ConfirmMe()" Text="Submit" runat="server"/>

Whenever you press the button with no textbox value, the client-side confirmation dialog will be invoked first before the validator message is able to show up. This isn't what we expected it to behave. I tried several ways to overcome this problem, including using CLIENT CALLBACK, disabling the CauseValidation, but it failed. Finally, I was able to find a solution by adding JUST ONE line in the JS script.

function ConfirmMe()
{
   if(Page_ClientValidate())
      return confirm('Do you want to proceed?');

return false;
}

Page_ClientValidate 用法的更多相关文章

  1. EditText 基本用法

    title: EditText 基本用法 tags: EditText,编辑框,输入框 --- EditText介绍: EditText 在开发中也是经常用到的控件,也是一个比较必要的组件,可以说它是 ...

  2. jquery插件的用法之cookie 插件

    一.使用cookie 插件 插件官方网站下载地址:http://plugins.jquery.com/cookie/ cookie 插件的用法比较简单,直接粘贴下面代码示例: //生成一个cookie ...

  3. Java中的Socket的用法

                                   Java中的Socket的用法 Java中的Socket分为普通的Socket和NioSocket. 普通Socket的用法 Java中的 ...

  4. [转载]C#中MessageBox.Show用法以及VB.NET中MsgBox用法

    一.C#中MessageBox.Show用法 MessageBox.Show (String) 显示具有指定文本的消息框. 由 .NET Compact Framework 支持. MessageBo ...

  5. python enumerate 用法

    A new built-in function, enumerate() , will make certain loops a bit clearer. enumerate(thing) , whe ...

  6. [转载]Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法总结

    本文对Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法进行了详细的总结,需要的朋友可以参考下,希望对大家有所帮助. 详细解读Jquery各Ajax函数: ...

  7. 【JavaScript】innerHTML、innerText和outerHTML的用法区别

    用法: <div id="test">   <span style="color:red">test1</span> tes ...

  8. chattr用法

    [root@localhost tmp]# umask 0022 一.chattr用法 1.创建空文件attrtest,然后删除,提示无法删除,因为有隐藏文件 [root@localhost tmp] ...

  9. 萌新笔记——vim命令“=”、“d”、“y”的用法(结合光标移动命令,一些场合会非常方便)

    vim有许多命令,网上搜有一堆贴子.文章列举出各种功能的命令. 对于"="."d"."y",我在无意中发现了它们所具有的相同的一些用法,先举 ...

随机推荐

  1. Android 蓝牙开发之A2DP基本功能

    本文主要是Android做为Audio Source端,A2DP的基本操作:包括连接.断开连接.设置优先级.获取优先级.获取A2DP连接状态.获取A2DP连接的设备列表等功能. 1.简介 Audio ...

  2. 五中不同的思路输出helloword

    五中不同的思路输出helloword -- 我也不知道了--

  3. JS中confirm,prompt用法

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. java String->float,float->int

    类型转换代码 : String sourceStr = "0.0"; String类型 float sourceF = Float.valueOf(sourceStr); floa ...

  5. 06-spring学习-自动装配

    自动装配前面也有写过.这里只做补充 在之前,对于要引用的属性,都必须写上名称, 原始配置: 当要在emp对象里面引用dept对象的时候,需要明确的使用“ref“属性去找到指定的名称,但是这种操作中也可 ...

  6. centOS7 安装redis-3.2.6

    0.下载tar.gz包并解压到某个位置,然后cd进入解压后的目录(redis-3.2.6)下 1.安装 make MALLOC=libc 关于为什么这样做,参考redis-3.2.6目录下的READM ...

  7. 乐鑫esp8266基于freeRtos实现私有服务器本地远程OTA升级

    目录 一.前言: 二.回顾下OTA的流程: 三.lwip网络框架的知识的使用: 四.如何处理服务器返回的数据? 五.扇区的擦除和烧写? 六.如何调用? 七.好好享用吧! 八.下载: 九.工程截图: 代 ...

  8. c# webbrowser 清除cookie和缓存

    由于缓存文件是特殊的文件,以及WebBrowser与IE版本有关因此删除缓存绝对不可能用一些IO函数就总可以解决的因此我的这些函数在IO操作的基础上,又针对环境进行相应的清理. static clas ...

  9. T-sql for xml path使用

    用法: FOR XML PATH 方法是用于将查询结果集以XML形式展示 sql: p.ContactTypeID,p.ModifiedDate,p.Name from [Person].[Conta ...

  10. java读取本地txt文件并插入数据库

    package com.cniia.ny.web.control.configManage; import java.io.BufferedReader; import java.io.File; i ...