View Single Post
  #3 (permalink)  
Old July 2nd, 2010, 05:33 AM
AdamPembs AdamPembs is offline
Authorized User
 
Join Date: Jan 2010
Location: Wales, UK
Posts: 31
Thanks: 5
Thanked 2 Times in 2 Posts
Default

Thanks Imar, took me 30 minutes to integrate the new code for the CKEditor.
The only thing I'm not completely happy about is having to use ctl00$MainContentPlaceholder$txtBodyText as the format for the javascript names. I think asp.net 4.0 has a clientname ClientId property, but Im still on 3.5. There might be a better way of doing this...but its working for me.

I posted the code below (if you want them for a sticky or link) The admin.master has this in the head section
Code:
 <script type="text/javascript" src="../ckeditor/ckeditor.js"></script>
(Im having problems with virtual paths on this, so had to use .. parent path)

AddEditContent.aspx
Code:
<%@ Page Language="VB" MasterPageFile="~/AdminMaster.master" AutoEventWireup="false" CodeFile="AddEditContent.aspx.vb" Inherits="AddEditContent" Title="Create New Content Item" ValidateRequest="false" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceholder" runat="Server">
  <table cellpadding="0" cellspacing="0" style="width: 720px" runat="server" id="tblContentItem">
  <tr>
    <td style="width: 120px" class="Label">Title</td>
    <td style="width: 600px">
      <asp:TextBox ID="txtTitle" runat="server" Width="600px" />
      <asp:RequiredFieldValidator ID="reqTitle" runat="server" ControlToValidate="txtTitle" ErrorMessage="The title is required">The title is required</asp:RequiredFieldValidator>
      <br />
    </td>
  </tr>
  <tr>
    <td class="Label">Intro Text</td>
    <td>
    <textarea name="txtIntroText" cols="50" rows="10" ID="txtIntroText" runat="server">
   
    &lt;p&gt;Initial value.&lt;/p&gt;</textarea>
     
    </td>
  </tr>
  <tr>
    <td class="Label">Full Text</td>
    <td>
    <textarea name="txtBodyText" cols="50" rows="10" ID="txtBodyText" runat="server">
    </textarea>
     
    </td>
  </tr>
  <tr>
    <td class="Label">Content type</td>
    <td>
      <asp:DropDownList ID="lstContentTypes" runat="server" AutoPostBack="True" DataSourceID="sdsContentTypes" DataTextField="Description" DataValueField="Id"></asp:DropDownList>
      <br />
      <br />
    </td>
  </tr>
  <tr>
    <td class="Label">Category</td>
    <td>
      <asp:DropDownList ID="lstCategories" runat="server" DataSourceID="sdsCategories" DataTextField="Description" DataValueField="Id"></asp:DropDownList>
      <br />
      <br />
    </td>
  </tr>
  <tr>
    <td class="Label">Visible?</td>
    <td>
      <asp:CheckBox ID="chkVisible" runat="server" />
      <br />
      <br />
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
      <asp:Button ID="btnSave" runat="server" Text="Save" CausesValidation="False" />
      <asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false" />
    </td>
  </tr>
  </table>
  <asp:SqlDataSource ID="sdsContentTypes" runat="server" ConnectionString="<%$ ConnectionStrings:Cms %>" SelectCommand="sprocContentTypeSelectList" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
  <asp:SqlDataSource ID="sdsCategories" runat="server" ConnectionString="<%$ ConnectionStrings:Cms %>" SelectCommand="sprocCategorySelectlist" SelectCommandType="StoredProcedure">
    <SelectParameters>
      <asp:ControlParameter ControlID="lstContentTypes" Name="contentTypeId" PropertyName="SelectedValue" Type="Int32" />
    </SelectParameters>
  </asp:SqlDataSource>
  
  <script type="text/javascript">
      CKEDITOR.replace('ctl00$MainContentPlaceholder$txtBodyText');
</script><script type="text/javascript">
             CKEDITOR.replace('ctl00$MainContentPlaceholder$txtIntroText');
</script>
</asp:Content>