Hi i am using ckeditor in asp.net. In a simple web page setData and getData function is working fine but when i am running the same code in an another page Inherits with a master page then i am getting error.
Code is :
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script src="js/jquery-1.10.2.min.js"></script>
<script>
$(document).ready(function () {
$('.active').click(function () {
alert(CKEDITOR.instances['txt'].getData());
})
})
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<ckeditor:ckeditorcontrol runat="server" id="txt" name="" width="870"></ckeditor:ckeditorcontrol>
<span style="margin:20px!important;cursor:pointer" class="active">testing</span>
</asp:Content>
Error is : Uncaught TypeError: Cannot read property 'getData' of undefined
system is unable to read the ID of ckeditor because with master page convert the client ID of the controls like in your example without master page id is "txt" and with master page ID is like "ContentPlaceholderID_txt". So you can use ClientIDMode="Static" for ckeditor. Like below:-
<ckeditor:ckeditorcontrol runat="server" id="txt" name="" width="870" ClientIDMode="Static"></ckeditor:ckeditorcontrol>
I think this will resolve your problem.