Show
Ignore:
Timestamp:
2008-07-25 07:44:28 (6 months ago)
Author:
fredck
Message:

Fixed #234 (2/2) : Fixed the incompatibility with the Microsoft ASP.Net AJAX UpdatePanel.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor.Net/trunk/FCKeditor.cs

    r2024 r2282  
    4545        public class FCKeditor : System.Web.UI.Control, IPostBackDataHandler 
    4646        { 
     47                private bool _IsCompatible ; 
     48 
    4749                public FCKeditor() 
    4850                {} 
     
    343345                        writer.Write( "<div>" ) ; 
    344346 
    345                         if ( this.CheckBrowserCompatibility() ) 
     347                        if ( _IsCompatible ) 
    346348                        { 
    347349                                string sLink = this.BasePath ; 
     
    389391 
    390392                        writer.Write( "</div>" ) ; 
     393 
     394                } 
     395 
     396                protected override void OnPreRender( EventArgs e ) 
     397                { 
     398                        base.OnPreRender( e ); 
     399                         
     400                        _IsCompatible = this.CheckBrowserCompatibility(); 
     401 
     402                        if ( !_IsCompatible ) 
     403                                return; 
     404 
     405                        object oScriptManager = null; 
     406 
     407                        // Search for the ScriptManager control in the page. 
     408                        Control oParent = this.Parent; 
     409                        while ( oParent != null ) 
     410                        { 
     411                                foreach ( object control in oParent.Controls ) 
     412                                { 
     413                                        // Match by type name. 
     414                                        if ( control.GetType().FullName == "System.Web.UI.ScriptManager" ) 
     415                                        { 
     416                                                oScriptManager = control; 
     417                                                break; 
     418                                        } 
     419                                } 
     420 
     421                                if ( oScriptManager != null ) 
     422                                        break; 
     423 
     424                                oParent = oParent.Parent; 
     425                        } 
     426 
     427                        // If the ScriptManager control is available. 
     428                        if ( oScriptManager != null ) 
     429                        { 
     430                                try 
     431                                { 
     432                                        // Use reflection to check the SupportsPartialRendering 
     433                                        // property value. 
     434                                        bool bSupportsPartialRendering = ((bool)(oScriptManager.GetType().GetProperty( "SupportsPartialRendering" ).GetValue( oScriptManager, null ))); 
     435 
     436                                        if ( bSupportsPartialRendering ) 
     437                                        { 
     438                                                string sScript = "(function()\n{\n" + 
     439                                                        "\tvar editor = FCKeditorAPI.GetInstance('" + this.ClientID + "');\n" + 
     440                                                        "\tif (editor)\n" + 
     441                                                        "\t\teditor.UpdateLinkedField();\n" + 
     442                                                        "})();\n"; 
     443 
     444                                                // Call the RegisterOnSubmitStatement method through 
     445                                                // reflection. 
     446                                                oScriptManager.GetType().GetMethod( "RegisterOnSubmitStatement", new Type[] { typeof( Control ), typeof( Type ), typeof( String ), typeof( String ) } ).Invoke( oScriptManager, new object[] { 
     447                                                        this, 
     448                                                        this.GetType(), 
     449                                                        "FCKeditorAjaxOnSubmit_" + this.ClientID, 
     450                                                        sScript } ); 
     451 
     452                                                // Tell the editor that we are handling the submit. 
     453                                                this.Config[ "PreventSubmitHandler" ] = "true"; 
     454                                        } 
     455                                } 
     456                                catch { } 
     457                        } 
    391458                } 
    392459