惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
美团技术团队
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
aimingoo的专栏
aimingoo的专栏
腾讯CDC
WordPress大学
WordPress大学
Apple Machine Learning Research
Apple Machine Learning Research
F
Fortinet All Blogs
G
Google Developers Blog
MongoDB | Blog
MongoDB | Blog
Microsoft Azure Blog
Microsoft Azure Blog
小众软件
小众软件
Engineering at Meta
Engineering at Meta
博客园_首页
B
Blog RSS Feed
D
Docker
M
MIT News - Artificial intelligence
爱范儿
爱范儿
I
InfoQ

博客园 - 从无到有.NET

[转帖]如何提升JavaScript操作DOM的效率 揭开正则表达式的神秘面纱 比较完整的一个 Ajax 类库汇总 解决“未能创建 Mutex”的问题 解决ASP.NET的进程帐户没有访问IIS的权限 MSN Messenger去广告和其他修改方法 - 从无到有.NET - 博客园 如何取消“本页不但包含安全的内容,也包含不安全的内容。是否显示不安全的内容。” 的提示 【转贴】datagrid数据导出到excel文件给客户端下载的几种方法 ASP.NET 中的正则表达式 asp.net TreeView安装、使用(如何将TreeView打包发布)(带CheckBox选择框的TreeView的初始化,TreeView客户端操作:选择父节点后自动选择所有子节点,子节点选择后自动选择父节点)(TreeView节点精确定位) 使用C#调用外部Ping命令获取网络连接情况 在.Net中嵌入资源文件到程序集中 RegularExpressionValidator 【原创】如何去掉有源代码管理的项目中的相关信息 关于PHP--session的问题集锦解决方案 php和asp对象的等价关系 My SQL出错代码及出错信息对照 Windows 环境下的 PHP5 与 Apache 服务器的配置 php.ini中文解释
FCKEditor使用RequiredFieldValidator验证时必须点击两次的解...
从无到有.NET · 2006-10-19 · via 博客园 - 从无到有.NET

FCKEditor是一个很不错的在线编辑器,可称得上完美,但是它有一个问题,就是在使用RequiredFieldValidator进行验证的时候,即使内容不为空,也需要点击两次才能完成,经过查找网上的资料,发现好像是它本身的一个问题,原文如下:

With ASP.Net, I need to submit twice when using the RequiredFieldValidator in a FCKeditor instance

FCKeditor will not work properly with the Required Field Validator when the "EnableClientScript" property of the validator is set to "true" (default). Due to a limitation in the default validation system, you must set it to "false".

If you want to do client side validation, you must use a Custom Validator instead and provide the appropriate validation function, using the FCKeditor JavaScript API.

译文如下(翻译的不好,大家能看懂就好):
问:为什么在使用ASP.NET的RequiredFieldValidator时,我需要提交两次
答:当RequiredFieldValidator的EnableClientScript属性被设置成true时,FCKEditor不能很好的支持RequiredFieldValidator,为了解除这个限制,你必须把这个属性设置成为false
如果你希望使用客户端验证,你必须使用Custom Validator制作一个非空验证来替换RequiredFieldValidator,在其中使用FCKeditor JavaScript API即可。

看了这篇文章,我就去找FCKeditor JavaScript API的文档,发现它为客户端JavaScript的调用提供了一些属性和方法,于是乎,就按上述的回答写了一段JavaScript脚本来完成了验证。

详细解决方法:首先添加Javascript脚本:
<script language="javascript"  type="text/javascript">
var oEditer;
function CustomValidate(source, arguments)
{
    var value = oEditer.GetXHTML(true);
    if(value=="")
    {
       arguments.IsValid = false;    
    }
    else
    {
        arguments.IsValid = true;
    }
}
function FCKeditor_OnComplete( editorInstance )

    oEditer = editorInstance;
}
</script>
然后添加CustomValidator,设置ClientValidationFunction="CustomValidate",注意千万别忘了ValidateEmptyText="True",否则不起作用!
这样,再试试,哈哈,一次就可以直接提交了,不会出现提交两次的bug了。