CKEditor.Net Does Not Work Inside Multiview

I’ve written in a post a few months ago about a javascript-based lightweight WYSIWYG rich-text editor that can be used in web pages called FCKEditor. The developers have upgraded it and called it CKEditor. I tried to use it two days ago and up until now, I still cannot use it for my specific purpose. I am near the end of a project with this WYSIWYG editor as the second-to-the-last-module. I am convinced that I have encountered a bug and have yet to find a solution. I will blog about this for documentation purposes.

CKEditor + AJAX + UpdatePanel + Multiview = Problem

The bug I am encountering now appears only on when the conditions are right. I created a new AJAX-enabled website project in Visual Studio 2008 with C# as my code-behind. I downloaded the latest (as of time of writing) version of CKEditor 3.5.2 and CKEditor.Net 3.5.2 control from their website.

From Solution Explorer in VS2008, I added a BIN folder and placed the `CKEditor.NET.dll` (from CKEditor.Net 3.5.2) there. The ckeditor folder that contains the core files (from CKEditor 3.5.2) was also placed in the root of the website. I opened the Web.Config file and added the following line to the node:

<add tagPrefix="CKEditor" namespace="CKEditor.NET" assembly="CKEditor.NET" />

Then, I opened Default.aspx and add the following line:

<CKEditor:CKEditorControl runat="server" ID="tbContent1" />

So that the whole Default.aspx would look like this:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    
</form> </body> </html>

If you try to view it by debugging it (hit CTRL+F5 while on VS2008), you should see the CKEditor.Net Control working as intended.

Now if we put the CKEditor.Net control inside an update panel, it would still work. If the update panel contains a multiview control with only one view panel and the CKEditor.Net control is inside the only view panel, it would still also work. But once the multiview control has two or more view panels and the CKEditor.Net control is on the second view panel (or any panel for that matter, as long as it is not on the default active view index of the multiview) that’s where things start to get ugly.

We can change the code of Default.aspx to:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    
</form> </body> </html>

Notice the button on the first view panel. We’ll be using that to switch the active view index of the multiview control to the second view panel. We need to handle the OnClick event of that button so we do the whole code-behind (Default.aspx.cs) file like so:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btn_Click(object sender, EventArgs e)
    {
        //MultiView1.ActiveViewIndex = 1;
    }
}

Once we debug it again (CTRL+F5 while on VS2008), we get a button on the initial page load since the multiview’s active view index property is set to zero (ActiveViewIndex=”0″). If we click on the button, the OnClick event of the button sets the multiview’s active view index to 1 (where the CKEditor.Net contol is at). This produces a javascript error and the CKEditor.Net control is rendered as a plain textbox.

 

Line: 5
Error: Sys.ScriptLoadFailedException: The script '/CKEditorMultiview/ckeditor/ckeditor.js?t=B1GG4Z6' could not be loaded.

 

It happens on Internet Explorer 8.0.7601.17514, Google Chrome 10.0.648.151, FireFox 3.6.13 (although the javascript error does not show on GC and FF – might be a in-browser error config thing – the CKEditor.Net being rendered as a plain textbox is present on all three major browsers).

As I’ve said at the start of this post, I have not yet found a solution to this problem. If you have any information on how to fix this particular problem, kindly drop me a line at the comments. Thanks!

Over Speeding at SCTEX

So I got an over speeding ticket.

Last Saturday (March 5, 2011), I went with my fiancée’s clan for a summer outing. At around 7:30AM we were at SCTEX’s Clark South toll booth. The expressway is still very nice to drive on and is very very free from congestion. Running at a 100kph seems like 60kph as you zoom past the green scenery.

Apprehension

Call me crazy and irresponsible (and guilty as well) since we were on a 4-car convoy going to Subic with speeds in excess of 160kph. I was the last car on the convoy and all the while, they were moving from left to right and vice versa, weaving our way through the other cars. Most of the time I stayed on the left lane (over taking lane) even if there were no cars on the right lane (slow/cruising lane) while the other cars in our convoy kept returning to the right lane. I also noticed that there was a parked white pickup truck on the side of the road a few kilometers before the exit booth at Subic. Why am I saying all this? Because these are the tell tale signs that they’re on to you. Heh.

Upon reaching the exit booth at Subic, I was immediately flagged by the traffic enforcers and guided me to stop the car on the shoulder lane. I opened my window and was told that they detected that I was over speeding and that they’d like to see my license. I gave the apprehending officer my driver’s license and upon seeing my address, he asked me as if to confirm “Sir, taga Caloocan po kayo? (Are you from Caloocan City?)” I said yes and he walked away with my license.

A few minutes later, he returned with the traffic violation ticket already filled out and explained to me that I was caught by their speed gun running at 129kph (!?). I asked him a few questions and I learned that although the “advertised” speed limit at SCTEX is 100kph, a 15% speed allowance is given to motorists in the event that the car needs to speed up to overtake another car. I asked why was I the only one caught over speeding when in fact, there were four of us. He said some BS excuse and just offered some tips so that I won’t be caught next time (at this point I felt really weird because I was with my fiancée, her mom, her cousin and there I was guilty as hell and the guy who just apprehended me is giving me tips on how to beat their system).

I was also told that there would be a picture of my car with the speed reading superimposed on it as proof but can only be showed when I claim my license. He said that since I live in Caloocan, I will be claiming my license at the Land Transportation Office’s (LTO) main office at East Ave. in Quezon City. In lieu of my license, I was given a temporary license which is good for 3 working days. 

Claiming My License

I went to the LTO main office on Wednesday (March 9, 2011) at around 2:30PM. I asked the guard in the parking lot where to go next. I was with my dad who was going to renew his license (expired for more than a year!!!).

The processing was fast but was a bit unorganized. I went in to one building to have my violation ticket be numbered for a queue then waited for about 15 mins. before my number was called. I went to the personnel who called my number and gave me a sheet of paper with the break down of the charges that I need to pay first. PhP 1,000.00 for Reckless Driving, PhP 200.00 for Research and Legal fees and a few more (around 60.00) for computerization and training fees (!?) for a total of 1,26x.xx pesos.

The cashier is at another building and took me another 15 minutes. After I was issued a receipt, I was not told where to go next. There wasn’t any postings or directions for the next step. I went back to the first building and asked the guard where to go next.

I went to another building where the exam and film showing (a.k.a. the seminar) is held. The questionnaire is 60 items (multiple choice type of exam) and I was given three pieces of paper: (1) Pre-exam answer sheet, (2) Case details and (3) Post-seminar. The pre-exam answer sheet should be filled up using “stock knowledge” before the short film is shown. The case details was filled out with the case number, ticket violation number, license number, dates and other information related to the apprehension. The post-seminar sheet was filled out during the short film’s playback. As the instructor said, “If ever you get your answers in the pre-exam sheet wrong, write the correct answer in the post-seminar sheet.” I guess they were hoping that the mistakes made on the pre-exam sheet will be realized by the ones taking the exam due to the short film’s playback.

The film was short. I guess it was less than 30 mins. but was really boring. It starts with the history of transportation from (and I kid you not) carabaos, the naming history of the LTO and the requirements for applying for a student and non-professional license. Ok the film might not have started with saying that transportation started from carabaos but it was that freaking boring. It was very illogical as well since our violation was reckless driving and not driving without a license. The exam never had a question that touched on the name or history of the LTO nor did the short film discuss the tonnage limit per axle on an 18-wheeler truck which was a question on the exam. I think this is the “torture” part for those who violated traffic rules.

After submitting the exam, we had to wait for what seemed like eternity on the 2nd floor of the same building. And in true graduation-style roll call, we are given a certificate of exam completion and a booklet entitled “The Filipino Drivers Manual”.

Upon receiving the certificate of exam completion, I went to the 2nd floor of the 1st building that I went to where I had to surrender all certificates, tickets and receipt then wait for my name to be called. The only thing that I got back was my license and my receipt.

It was about 4:50PM when I got back to the car with my license, booklet-souvenir and my dad waiting patiently. He was done renewing his license for about 30mins already.

So if you’d want to speed up along SCTEX or NLEX, make sure you allot about half a day and PhP1,500.00 to get your license back. hahaha!