With ASP.Net, I need to submit twice when using the RequiredFieldValidator in a FCKeditor instance FCKeditor will not work properly with the Requ " /> 国产精品自拍网站,成人高潮a毛片免费观看网站,gay欧美网站

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

asp.net 控件驗證 FCKeditor

經(jīng)過查找網(wǎng)上的資料,發(fā)現(xiàn)好像是它本身的一個問題,原文如下:

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時,我需要提交兩次
答:當(dāng)RequiredFieldValidator的EnableClientScript屬性被設(shè)置成true時,F(xiàn)CKEditor不能很好的支持RequiredFieldValidator,為了解除這個限制,你必須把這個屬性設(shè)置成為false 如果你希望使用客戶端驗證,你必須使用Custom Validator制作一個非空驗證來替換RequiredFieldValidator,在其中使用FCKeditor JavaScript API即可。 

       看了這篇文章,我就去找FCKeditor JavaScript API的文檔,發(fā)現(xiàn)它為客戶端JavaScript的調(diào)用提供了一些屬性和方法,于是乎,就按上述的回答寫了一段JavaScript腳本來完成了驗證。

詳細(xì)解決方法:首先添加Javascript腳本:
復(fù)制代碼 代碼如下:
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,設(shè)置ClientValidationFunction="CustomValidate",注意千萬別忘了ValidateEmptyText="True",否則不起作用!

這樣,再試試,OK,一次就可以直接提交了,不會出現(xiàn)提交兩次的bug了

AspNet技術(shù)asp.net 控件驗證 FCKeditor,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 永顺县| 灌南县| 波密县| 龙陵县| 贡嘎县| 洞口县| 安新县| 宜兰市| 鸡东县| 泾阳县| 蕲春县| 临桂县| 水富县| 松桃| 东阿县| 扬州市| 上杭县| 平陆县| 龙陵县| 新和县| 独山县| 马龙县| 宁都县| 徐水县| 肥西县| 吴桥县| 突泉县| 东方市| 双流县| 六盘水市| 石渠县| 礼泉县| 兰考县| 克东县| 涪陵区| 高碑店市| 山阳县| 桐乡市| 资中县| 大荔县| 富民县|