本文转自:http://stackoverflow.com/questions/2083929/dropdownlist-doesnt-postback-after-page-clientvalidate

Update:

I have just found the solution. The following function works (remove the else part):

function confirmSubmit() {
if (Page_ClientValidate("Group1")) {
return window.confirm("Are you sure to submit the form?");
}
}

But I am wondering why it doesn't work when I add the else part.

Question:

I want to have a confirm dialog after user fills in all the data in the form. I set onclientclick="return confirmSubmit()" in the submit button.

 function confirmSubmit() {

     if (Page_ClientValidate("Group1")) {
return window.confirm("Are you sure to submit the form?");
} else { return false;
}
}

If Page_ClientValidate("Group1") returns false, the dropdownlist doesn't cause postback after I first select the item, and the postback only occurs when I select the dropdownlist second time.

What's the problem?

asked Jan 18 '10 at 4:37
Billy

5,473225691
 
1  
Your validation rules are saying the page is invalid and causing the postback to stop...which is what they're supposed to do. Can you post the markup for your validators? One of them in Group1 is saying that it's not in a valid state. – Nick Craver♦ Jan 18 '10 at 4:46
    
I have found the solution. – Billy Jan 18 '10 at 4:56

2 Answers

After Page_ClientValidate is called, the variable Page_BlockSubmit gets set to true, which blocks the autopost back. Page_BlockSubmit was getting reset to false on the second click, for what reasons I still don't fully understand. I'm looking more into this, but I have a solution and I'm under the gun so I'm rolling with it....

Just add below code in the code block which executes if Page is not valid.

Page_BlockSubmit = false;

e.g.

function ValidatePage()
{
flag = true;
if (typeof (Page_ClientValidate) == 'function')
{
Page_ClientValidate();
} if (!Page_IsValid)
{
alert('All the * marked fields are mandatory.');
flag = false;
Page_BlockSubmit = false;
}
else
{
flag = confirm('Are you sure you have filled the form completely? Click OK to confirm or CANCEL to edit this form.');
}
return flag;
}

[转]Dropdownlist doesn't postback after Page_ClientValidate()的更多相关文章

  1. 解决dropdownlist postback 在 iphone UIwebview 失效的问题

    原因: IPhone UIWebView 的 用户代理 User Agent 在ASP.NET 4.0环境下是不识别的:所以ASP.NET提供了一个默认的,低级的不包括javascript的页面版本 ...

  2. "不能在 DropDownList 中选择多个项。"其解决办法及补充

    探讨C#.NET下DropDownList的一个有趣的bug及其解决办法 摘要: 本文就C#.Net 环境下Web开发中经常使用的DropDownList控件的SelectedIndex属性进行了详细 ...

  3. IsPostBack and DropdownList.

    Encounted the issue accident when helping my classmate dealing with his homework assignment,it turns ...

  4. Asp.net中Postback及Callback

    我们知道,在默认的情况下,当我们点击Asp.net Page中的一个服务器Button时(默认其实是Submit Form),会导致Page被Recreated,这个过程我们称之为Postback,它 ...

  5. jQuery UI Autocomplete Combobox 配 ASP.NET DropDownList

    0.引言   1.起因                  一开始使用Autocomplete做了一个自动补全的文本框,如上图.后来因业务需要希望能在这个文本框的边上做个下拉列表按钮,一按就展开所有支持 ...

  6. Understanding The Complete Story of Postback in ASP.NET

    https://docs.microsoft.com/zh-cn/dotnet/api/system.web.ui.page.ispostback?view=netframework-4.7 http ...

  7. Asp.Net 将枚举类型(enum)绑定到ListControl(DropDownList)控件

    在开发过程中一些状态的表示使用到枚举类型,那么如何将枚举类型直接绑定到ListControl(DropDownList)是本次的主题,废话不多说了,直接代码: 首先看工具类代码: /// <su ...

  8. DropDownList 下拉框选择改变,促发事件和防全局刷新(记录)

    代码: <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:Script ...

  9. DropDownList实现可输入可选择

    1.js版本 <div style="z-index: 0; visibility: visible; clip: rect(0px 105px 80px 85px); positio ...

随机推荐

  1. linux常用命令之文件管理

    LS ls:list directory contents 默认情况 默认情况下显示的是mtime 选项 -a 列出全部文件及目录包括隐藏的 -l 列出详细信息,包括文件类型.权限.节点.owner. ...

  2. Web 前沿——HTML5 Form Data 对象的使用

    XMLHttpRequest Level 2 添加了一个新的接口——FormData.利用 FormData 对象,我们可以通过 JavaScript 用一些键值对来模拟一系列表单控件,我们还可以使用 ...

  3. visual studio 查找/替换对话框

    工具--选项--环境--查找和替换 如下设置: 则会在查找.替换到最后时会弹出提示,比如“查找到达了搜索的起点”,如下图: 原文:http://keleyi.com/a/bjac/27iswh0p.h ...

  4. LigerUi框架+jquery+ajax无刷新留言板系统的实现

    前些天发布了LigerUi框架的增.删.改代码,一堆代码真的也没一张图片.有的网友推荐上图,所有今天把涉及到这个框架的开源的留言板共享给大家.在修改的过程中可能有些不足的地方希望大家拍砖. 因为留言板 ...

  5. ionic + cordova 使用 cordova-gallery-api 获取本地相册所有图片

    cordova-gallery-api 插件定义一个全局galleryapi对象,提供查询图库相册的方法 安装 cordova-gallery-api: cordova plugin add http ...

  6. ABAP 动态生成内表的几种方法

    最近要写个程序,既有更新的,也有删除的,需要涉及到很多系统表,如果一个表一个表进行更新或者删除太慢了,于是就想通过创建动态内表来实现这些功能,在网上找了一些资料,经过多次尝试,终于测试成功了.网上讲述 ...

  7. java发送固定字节到C++接口

    需求:java工程需要发送一个socket消息到C++接口,C++接口中规定了若干个参数,并且每个参数的长度是固定的,起始位置也是固定的, C++那边是GB2312编码,java这边是UTF-8. 现 ...

  8. Linux学习心得之 jnlp的文件和java应用程序安全设置

    作者:枫雪庭 出处:http://www.cnblogs.com/FengXueTing-px/ 欢迎转载 jnlp的文件和java应用程序安全设置 1.前言2. jnlp的文件打开3.java应用程 ...

  9. git stash提交PR的正确步骤&git squash技术

    1.git stash梳理 1.1git stash的克隆与同步 首先整理下git stash的逻辑是这样 在本地做出了新的修改,提交时显示当前的版本不是最新版本,这时就需要先pull一下自己代码仓库 ...

  10. Android之滑屏动画和自定义控件

    滑屏动画 在Android系统中,通过手势识别切换界面时,通常会在界面切换时加入动画,以提高用户的体验效果,这种动画一般都采用平移动画,下一个界面进入时,上一个界面移除屏幕. 图中标识的均为左上角坐标 ...