2009-12-21 107 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