Saturday, October 20, 2007

FckEditor inside UpdatePanel broken

FckEditor (or Fck) is a lightweight, JavaScript based WYSIWYG html editor for web applications.  I find it one of the best html editors out there along with FreeTextBox (or FTB), a popular ASP.NET-centric html editor.  The best thing about both of the editors is that they are free.  The advantage of Fck it that is works with a couple of different web platforms including Java, PHP, and .NET.  However, one thing I have found lacking is the FckEditor's documentation

HTML Editor solutions usually rely on an iframe or div to be the actual html editor so they require a second hidden input field to be the input field that will post the value of the editor back to the server.  This is normally not a problem because they usually update the input field before the form is posted.  However the Microsoft AJAX UpdatePanel does not do normal form posts, so html editors like Fck and FTB don't get a chance to update their linked field.  I have yet to see an official fix from the developers of both these solutions.  Many people have asked "which editors work with UpdatePanel?", including the html editors that are not free including Telerik's RadEditor and Infragistics' NetAdvantage WebHtmlEditor.

I found two different solutions for fixing the FckEditor UpdatePanel updating problem.  The first solution handles the onclick event that triggers the async postback and then use a client-side JavaScript function to update the hidden linked input field.  The second solution I found was better because it attached to the OnSubmit event which works with both synchronous and asynchronous postback calls.  The second solution also updated all of the editors on the page instead of a specific one - the reason why I was looking for another solution in the first place.

Here is the C# code for the second solution (for the Page_Load event):

    "for ( var i = 0; i < parent.frames.length; ++i ) if ( parent.frames[i].FCK ) parent.frames[i].FCK.UpdateLinkedField();"


Friday, October 12, 2007

.NET Framework Source Code to be Released

There is great news on the .Net front as Scott Guthrie announced that the source code .Net 3.5 is going to release under Microsoft Reference License (MS-RL).  However this is not full open source license like Microsoft Permissive License (Ms-PL), which will soon be renamed the Microsoft Open License.  Ms-PL allows derivative works unlike Ms-RL where you can't copy the code.  So Mono developers are encouraged to not look at the reference code and keep on reverse engineering .Net.  I do assume that because it is a reference license, you can make references to the source code (on say a blog), although I am not an expert on copyright law.

Shawn Burke is one of the people that drove the initiative to deliver the source code, in fact on his blog in 2005 he said "I want to deliver Windows Forms source code to you".  In fact, Shawn Burke talks about the history of this release in a podcast "Interview with Shawn Burke on Microsoft's .Net Source Code Release".  Please note that this is not Rotor (an open source, reference implementation of .Net).  This is also not Mono, the Novell led reverse engineered version of .Net.  This is also not code de-complied from Lutz Roeder's .Net  Relector.  Many developers have been "peeking under the hood" of .Net for quite a will now using Reflector, but this does not show the original source code just the source code "intent" as it is complied.  Java has had its source code for available for as long as I can remember.  Having the Java source code helped me become an expert quicker than developers that didn't read the source code.

One of the best parts is we are going to be able to step through the .Net source code using VS 2008 because Microsoft is also going to be providing the debug symbols as well.  The debug symbols, which is what links the source to each .Net DLL, are provided by a Microsoft symbol server which has been helping developers debug code for years.  I had looked into getting previous versions of .Net to be able to step through the code, but it required recompiling using ildasm and that didn't sound very desirable.

Congratulations to Shawn Burke, Scott Gu for providing us this valuable information!!!  This will help developers know more about the platform they are developing on as well as build higher quality code.

Monday, October 1, 2007

Error: The name '___' does not exist in the current context

Recently I got the following error "The name '___' does not exist in the current context" where '___' was the member variable of one of my controls.  I was really confused because even though it was a recently add control I was sure that I was doing it right.  So what else could be the problem?  Well it turns out that I had made a backup copy of the file in the same directory before I had changed it.  I turns out that in a Asp.Net 2.0 website you can't have two ASP.NET pages or user controls with the same name class name.  Because the pages are partial classes it does not give the error "The namespace '<global namespace>' already contains a definition for '_____'" like you would normally get if you redefined a class.  However it seemed that it only use one of the markup files to build the markup's partial class (or it could be that the second backup markup file overwrote the class for the first markup file).  Because it was using the markup partial class from the backup file and the new variable did not exist in that file I got the undefined variable error.  Also unlike ASP.NET 1.1 and 2.0 Web Application projects you can't have two classes with the same CodeFile.  Although it is not an error in a dynamically complied ASP.NET 2.0 website it is an HttpCompileException error in a precompiled ASP.NET website.  The ASP.NET 1.1 Installation Project also had problems with what it considered duplicate files where the main website's project would compile fine but when generating a msi installation package it would complain about the duplicate files.

AJAX Control Toolkit 10920 Released

On September 21, a new version of the AJAX Control toolkit was released.  The title of Delay's Blog's blog entry on it was "You voted lots, we fixed lots [AJAX Control Toolkit release!].  I thought the title was great because it shows a desire to add value to their customers and fulfill their wants/needs. 

Some of the biggest improvements in this release focus around the Calendar calendar extender.  In the previous version, I used the "textbox" activation for the calendar which means that instead of clicking a button to open the calendar you clicked on the textbox that had the current value.  I wanted to use the button activation using the extender's PopupButtonID property, but there was a problem that after you opened the calendar using the pop up button you had to select a date to close the pop up.  I would have expected that just clicking off would have closed the calendar.  In the new version you can now "click  off" to close.

In the blog "inventive title", Ron Buckton tells some of the changes and difficulty implementing them regarding the calendar.

The next version of Calendar needs to support the following activation scenarios depending on whether it is also associated with a button:

  • No Button
    • Show Popup when textbox receives focus
    • Show Popup when textbox is clicked
    • Hide Popup when textbox loses focus
    • Hide Popup when textbox receives ESC keypress
    • Hide Popup when a date is selected
  • Button
    • Show Popup when the button is clicked
    • Hide Popup when the button loses focus
    • Hide Popup when the button receives ESC keypress
    • Hide Popup when a date is selected

I have to that the control toolkit team for improving the activation of the calendar! Now I can use the popup button with my calendar.  Now if only there was a built in WSYSIWG editor.