2009-12-21 101 views
0

使用FCK编辑器控件代替textarea元素。我安装它没有问题。Fck编辑器问题

但是,当我想验证它与ASP.Net 2.0的自定义验证程序,我没有得到预期的结果。

这些线是我的代码:即执行的CustomValidator客户端功能是

<textarea style="width:30px;height:20px;" class="ckeditor" id="txtdescription" runat="server" name="txtdescription" cols="5" rows="10"></textarea> 

<asp:CustomValidator id="descval" runat="server" ControlToValidate="txtdescription" EnableClientScript="true" Enabled="true" ValidateEmptyText="true" Display="Dynamic" ClientValidationFunction="ValidateTextDesc" Text="*" ErrorMessage="*"/> 

<asp:Button ID="buttonadd" runat="server" Text="Add text" OnClick="buttonadd_Click" /> 

我的javascript代码:

function ValidateTextDesc(source, args) 
{ 
    var descriptiontext = document.getElementById("txtdescription"); 
if ((descriptiontext.value.indexOf("<script") != -1) || (descriptiontext.value.length==0)) 
{ 
    args.IsValid=false; 
} 
else 
{ 
    args.IsValid = true; 
} 
return args.IsValid; 
} 

我的问题是,我必须点击两次我提交按钮来执行这个客户端功能:

你知道为什么会发生这个问题吗? 在此先感谢。 此致敬礼。 Josema。

+0

FCK编辑器,听起来很兴奋。 – mipadi 2009-12-21 16:58:54

+1

这就是为什么它已被更名为CKEditor的最新版本:www.ckeditor.com – 2009-12-21 16:59:32

回答

1

线对于CKEditor的新版本的某处(3.0.2)的解决方案是使用:

CKEDITOR.instances.idoftextarea.getData();

最好的问候。

1

我在黑暗中拍摄的照片是FCKeditor在验证运行之前未将其内容传输到textarea。

在开始验证之前,您需要调用FCKEditor的函数手动发送内容。

应当沿着的FCKeditorAPI.GetInstance('FCKEditorFieldName').GetHTML()

+0

嗨, 在此先感谢您的快速响应,但我没有实例FCKeditorAPI。我有一个叫CKEDITOR,这个实例没有一个名为GetInstance的方法。我应该使用什么版本的FCKEditor。我的版本是从这里下载的:http://ckeditor.com/download是CKEditor 3.0.2 非常感谢。 此致敬礼。 Josema。 – Sosi 2009-12-21 17:12:14