ROY ROY - 9 days ago 5
Javascript Question

CKEditor getting displayed locally but not on iis server

I'm having trouble getting ckeditor to display in my web application. I can see the ckeditor textbox locally but nothing gets displayed on server.I tried few steps like adding on specific page , but still no resolution was reached.I can see ckeditor script on my browser but text box doesnot get displayed on browser.Below is the code :

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style type="text/css">
.auto-style1 {
width: 176px;
}
.auto-style2 {
width: 176px;
height: 54px;
}
.auto-style3 {
height: 54px;
}
.auto-style4 {
width: 176px;
height: 51px;
}
.auto-style5 {
height: 51px;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js" type="text/javascript"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="Stylesheet" type="text/css" />
<script type="text/javascript" src="../ckeditor/ckeditor.js"></script>

<table style="width: 100%; height: 333px;">
<tr>
<td class="auto-style1">&nbsp; Title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :&nbsp;</td>
<td>&nbsp; &nbsp;<asp:TextBox ID="txtTitle" runat="server" Height="29px" Width="451px" MaxLength="100"></asp:TextBox>
<asp:Label ID="lblNewsId" runat="server" Visible="False"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style1">&nbsp; Description&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :&nbsp;</td>
<td>&nbsp;&nbsp; &nbsp; <CKEditor:CKEditorControl ID="txtDescp" BasePath="/ckeditor/" runat="server">
</CKEditor:CKEditorControl>
</td>
</tr>
<tr>
</table>

Answer

Your script src is relative to your page location (starts with two dots): src="../ckeditor/ckeditor.js"

This means that if your asp.net page is located in a sub folder, then the ckeditor folder will not be found.

You can use ResolveClientUrl() to render the correct src at runtime:

<script type="text/javascript" src="<%=ResolveClientUrl("~/ckeditor/ckedtor.js")%>"></script>

Or, if you know the your application location will remain the same locally and remotely (for example http://localhost/myapp and also http://myserver/myapp) you can set the src starting from the root:

<script type="text/javascript" src="/myapp/ckeditor/ckedtor.js"></script>

Comments