I wish to use a ckeditor in a project that I've been working on. I followed the example showing in the link below. It worked perfectly with a normal asp page. However, if I use it in in a page that is part of a master page, it does not work for me. Can
someone please help?
Since the page is part of a master page, it does not contain the usual html tag such as form, body, etc..... I placed the code below in the contain2 area.
<div>
<asp:TextBox ID="TextBox1" TextMode="MultiLine" runat="server"
ontextchanged="TextBox1_TextChanged"></asp:TextBox>
<script type="text/javascript">
CKEDITOR.replace('TextBox1', { toolbar: 'CodeDigestTool' });
function GetText() {
alert(CKEDITOR.instances["TextBox1"].getData());
}
CKEDITOR.instances["TextBox1"].on("instanceReady", InstanceReadyEvent);
function InstanceReadyEvent() {
this.document.on("keyup", function () {
// var editor = CKEDITOR.instances.TextBox1;
var editor = CKEDITOR.instances["TextBox1"];
//Your code Goes here
var tex = editor.getData();
});
}
</script>
</div>
This part of the code was supposed to be in the <head> section of the page, so I put in the <head> section of the master page.
I am working with a textbox. When I ran the application, it displayed the textbox just as it were a normal textbox with multi line in of a word editor.
If I copy the same javascript code and paste it into the main master page, it works fine except that the editor appears on all other pages. When I copy it to a different page other than the master page, it only displays the textbox.
This issue has been fixed. The problem was that I had a masterpage, and I was passing 'Textbox1' in the ckeditor.Replace. It should be the clientID instead. So I added a variable in the page load (string id = TextBox1.ClientID); then, I did a response.write(id).
It display the clientID of the textbox which was 'ContentPlaceHolder1_TextBox1'. I replace TextBox1 with 'ContentPlaceHolder1_TextBox1' and run it - voila, it works.
CKEditorWord Editor
Regards,
Gagouche
Marked as answer by gagouche on Apr 22, 2010 08:27 PM
I was having the same issue; this solved it. The textbox control name is prefixed by the content placeholder name and "_". Thanks for posting your solution!
gagouche
Member
155 Points
172 Posts
CKEditor not working with Master Page
Apr 17, 2010 03:13 AM|LINK
I wish to use a ckeditor in a project that I've been working on. I followed the example showing in the link below. It worked perfectly with a normal asp page. However, if I use it in in a page that is part of a master page, it does not work for me. Can someone please help?
http://www.codedigest.com/Articles/ASPNET/315_Using_CKEditor_3x%5Baka_FCKeditor%5D_in_ASPNet.aspx
Since the page is part of a master page, it does not contain the usual html tag such as form, body, etc..... I placed the code below in the contain2 area.
<div> <asp:TextBox ID="TextBox1" TextMode="MultiLine" runat="server" ontextchanged="TextBox1_TextChanged"></asp:TextBox> <script type="text/javascript"> CKEDITOR.replace('TextBox1', { toolbar: 'CodeDigestTool' }); function GetText() { alert(CKEDITOR.instances["TextBox1"].getData()); } CKEDITOR.instances["TextBox1"].on("instanceReady", InstanceReadyEvent); function InstanceReadyEvent() { this.document.on("keyup", function () { // var editor = CKEDITOR.instances.TextBox1; var editor = CKEDITOR.instances["TextBox1"]; //Your code Goes here var tex = editor.getData(); }); } </script> </div>This part of the code was supposed to be in the <head> section of the page, so I put in the <head> section of the master page.
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
Gagouche
Chintan Dave
Contributor
3687 Points
742 Posts
Re: CKEditor not working with Master Page
Apr 17, 2010 07:07 AM|LINK
hey,
i faced same problem when i put FCKEditor in Update panel.
i solved it by removing update panel. but may me ur issues is differant.
please refer some related post as below:
http://p2p.wrox.com/book-asp-net-2-0-instant-results-isbn-978-0-471-74951-6/64239-fckeditor-not-working-contentplaceholder.html
http://www.eggheadcafe.com/community/aspnet/7/10045605/button-events-not-fired-f.aspx
I worked on FCK Editor and it is workin in both pages.
can u say what problme with FCK Editor ? Not working means not visible or content not update?
Thanks
http://napsterchintan.blogspot.com/
gagouche
Member
155 Points
172 Posts
Re: CKEditor not working with Master Page
Apr 18, 2010 12:02 AM|LINK
I am working with a textbox. When I ran the application, it displayed the textbox just as it were a normal textbox with multi line in of a word editor.
Gagouche
gagouche
Member
155 Points
172 Posts
Re: CKEditor not working with Master Page
Apr 18, 2010 01:28 AM|LINK
If I copy the same javascript code and paste it into the main master page, it works fine except that the editor appears on all other pages. When I copy it to a different page other than the master page, it only displays the textbox.
Gagouche
gagouche
Member
155 Points
172 Posts
Re: CKEditor not working with Master Page
Apr 18, 2010 03:08 AM|LINK
This issue has been fixed. The problem was that I had a masterpage, and I was passing 'Textbox1' in the ckeditor.Replace. It should be the clientID instead. So I added a variable in the page load (string id = TextBox1.ClientID); then, I did a response.write(id). It display the clientID of the textbox which was 'ContentPlaceHolder1_TextBox1'. I replace TextBox1 with 'ContentPlaceHolder1_TextBox1' and run it - voila, it works.
CKEditor Word Editor
Gagouche
colechna
Member
17 Points
6 Posts
Re: CKEditor not working with Master Page
Oct 08, 2010 07:36 PM|LINK
I was having the same issue; this solved it. The textbox control name is prefixed by the content placeholder name and "_". Thanks for posting your solution!
HostingRevie...
Member
38 Points
24 Posts
Re: CKEditor not working with Master Page
Oct 11, 2010 01:36 AM|LINK
Very good catch ... thanks for the update
raviraj bhat
Member
2 Points
1 Post
Re: CKEditor not working with Master Page
Nov 20, 2012 11:47 AM|LINK
To over come this problem following script will help u..
<script type="text/javascript">
var editor = CKEDITOR.replace('<%=editor.ClientID%>',
{
toolbar: 'myToolBar', skin: 'office2003', width: '100%'
});
</script>