asp.net 控件验证 FCKeditor
更新时间:2009年06月19日 23:32:24 作者:
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",否则不起作用!
这样,再试试,OK,一次就可以直接提交了,不会出现提交两次的bug了
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",否则不起作用!
这样,再试试,OK,一次就可以直接提交了,不会出现提交两次的bug了
相关文章
.NET Core跨平台资源监控工具CZGL.SystemInfo用法
这篇文章介绍了.NET Core跨平台资源监控工具CZGL.SystemInfo的用法,文中通过示例代码介绍的非常详细。对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2022-02-02
Asp.net Core MVC中怎么把二级域名绑定到特定的控制器上
这篇文章主要介绍了Asp.net Core MVC中怎么把二级域名绑定到特定的控制器上,需要的朋友可以参考下2017-06-06
ASP.NET(C#) String, StringBuilder 与 StringWriter性能比较
ASP.NET(C#) String, StringBuilder 与 StringWriter性能比较...2007-08-08
.net core webapi jwt 更为清爽的认证详解
这篇文章主要介绍了.net core webapi jwt 更为清爽的认证详解,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧2019-05-05
asp.net ext treepanel 动态加载XML的实现方法
当你在asp.net下面 使用Ext TreePanel直接加载服务器上XML文件会出现树不能显示,树据不能正确加载的问题。2008-10-10
.NET使用CsvHelper快速读取和写入CSV文件的操作方法
在日常开发中使用CSV文件进行数据导入和导出、数据交换是非常常见的需求,今天我们来讲讲在.NET中如何使用CsvHelper这个开源库快速实现CSV文件读取和写入,需要的朋友可以参考下2024-06-06


最新评论