FYI: How to make FCKeditor work in an UpdatePanel

Rate It (2)

Last post 09-10-2009 11:04 AM by skrowl. 60 replies.

Sort Posts:

  • Re: FYI: How to make FCKeditor work in an UpdatePanel

    04-11-2007, 11:26 AM
    • Member
      85 point Member
    • ctafield
    • Member since 12-15-2006, 10:58 AM
    • Lichfield, England
    • Posts 52

    I have changed my function to be :

    function () {
        if (FCK) {
            FCK.LinkedField.value = FCK.GetXHTML(FCKConfig.FormatOutput);
            FCK.Events.FireEvent("OnAfterLinkedFieldUpdate");
        }

    and it STILL doesn't work lol. Still says FCK is undefined on the if statement! I give up for now! :)

  • Re: FYI: How to make FCKeditor work in an UpdatePanel

    04-11-2007, 3:00 PM
    • Member
      69 point Member
    • joshcoady
    • Member since 02-16-2006, 8:48 PM
    • Rohnert Park, CA
    • Posts 30

    Try changing your if statement to

    if(typeof(FCK) != "undefined")
     
  • Re: FYI: How to make FCKeditor work in an UpdatePanel

    04-11-2007, 3:04 PM
    • Member
      69 point Member
    • joshcoady
    • Member since 02-16-2006, 8:48 PM
    • Rohnert Park, CA
    • Posts 30
    Or, just wrap it in a try..catch to suppress the error
  • Re: FYI: How to make FCKeditor work in an UpdatePanel

    04-11-2007, 4:07 PM
    • Member
      85 point Member
    • ctafield
    • Member since 12-15-2006, 10:58 AM
    • Lichfield, England
    • Posts 52
    Thanks Josh. I'll give it a whirl when I get into work tomorrow (am at home at the moment). I must emphasise that that code is from FCKEditor and not my own, but I'll try the suggestions :)
  • Re: FYI: How to make FCKeditor work in an UpdatePanel

    04-11-2007, 4:47 PM
    • Member
      69 point Member
    • joshcoady
    • Member since 02-16-2006, 8:48 PM
    • Rohnert Park, CA
    • Posts 30

    Are you guys trying the solution I posted to this forum or the updated version I posted here: http://jlcoady.net/archive/2007/03/30/fckeditor-work-inside-updatepanel?

    The updated version should suppress the error messages you are receiving while not forcing you to edit any of the FCK scripts.

    Let me know if it still doesnt work for you then I'll try to debug further.

  • Re: FYI: How to make FCKeditor work in an UpdatePanel

    04-11-2007, 4:57 PM
    • Member
      85 point Member
    • ctafield
    • Member since 12-15-2006, 10:58 AM
    • Lichfield, England
    • Posts 52

    Hadn't looked at your bersion before. The one I was personally using was this one: http://wiki.fckeditor.net/Troubleshooting#head-c83215c3393542ddc261fb2b7a64b60a41253d76

    I think, though, that your web site may actually solve my problem as I am doing what you mentioned, and that is hiding the text editor on a partial update. I think I need to wrap my code up with:

            if(typeof(FCKeditorAPI) == "object")
    {
    ... 

    and hopefully that should solve it.

     
    Thanks again Josh.
     

  • Re: FYI: How to make FCKeditor work in an UpdatePanel

    04-12-2007, 3:51 AM
    • Member
      85 point Member
    • ctafield
    • Member since 12-15-2006, 10:58 AM
    • Lichfield, England
    • Posts 52

    Hi Josh....

    I've totally removed my solution and implemented yours, and I'm still getting the error with FCK being undefined when in Firefox. Works a treat (or the error is supressed, one or the other!) in IE, but Firefox gives an error. You may only notice it if you're using Firebug...

  • Re: FYI: How to make FCKeditor work in an UpdatePanel

    04-17-2007, 8:36 PM
    • Member
      12 point Member
    • astrokid
    • Member since 04-18-2007, 12:31 AM
    • Posts 8

    Hi everyone, I'm new to this, is anyone can help?

     I got the "System.NullReferenceException: Object reference not set to an instance of an object." error.

      

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    2            If Not Page.IsPostBack() Then
    3             
    4    
    5              
    6    
    7                If Not Page.ClientScript.IsClientScriptBlockRegistered("FCKAjaxHack") Then
    8                    Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "FCKAjaxHack", String.Format("<script type=""text/javascript"" src='{0}'></script>", ResolveUrl("FCKHack.js")))
    9                End If
    10   
    11   
    12               btnSubmit.Attributes.Add("onClick", "if (eval('(typeof(MyFCKObject) != \'undefined\');')){MyFCKObject.UpdateEditorFormValue(); return true;}else{return true;}")
    13   
    14           End If
    15   
    16       End Sub
    
     
    I tried to find what cause the error, but no luck.
     

  • Re: FYI: How to make FCKeditor work in an UpdatePanel

    04-17-2007, 9:30 PM
    • Member
      69 point Member
    • joshcoady
    • Member since 02-16-2006, 8:48 PM
    • Rohnert Park, CA
    • Posts 30

    hmmm..it's hard to tell with the info you provided. Please turn on debugging and let us know what line of code is throwing the exception. The only place that seems like it could cause this error is the btnSubmit if there isnt a button on the page with id=btnSubmit

  • Re: FYI: How to make FCKeditor work in an UpdatePanel

    04-18-2007, 12:32 PM
    • Member
      12 point Member
    • astrokid
    • Member since 04-18-2007, 12:31 AM
    • Posts 8

      
     

    1        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    2            If Not Page.IsPostBack() Then
    3       
    4    
    5                If Not Page.ClientScript.IsClientScriptBlockRegistered("FCKAjaxHack") Then
    6                    Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "FCKAjaxHack", String.Format("<script type=""text/javascript"" src='{0}'></script>", ResolveUrl("FCKHack.js")))
    7                End If
    8    
    9    
    10               btnSubmit.Attributes.Add("onClick", "if (eval('(typeof(MyFCKObject) != \'undefined\');')){MyFCKObject.UpdateEditorFormValue(); return true;}else{return true;}")
    11   
    12           End If
    13   
    14       End Sub
    
     

    I place the editor in a updatepanel within a repeater within an other repeater. The error is on line 10. There must be something wrong with the btnSubmit button, but I'm sure I there is a button with the id "btnSubmit"

     Here is the stack trace if it helps

    [NullReferenceException: Object reference not set to an instance of an object.]
    admin_clientPMP.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\Admin\My Documents\Visual Studio 2005\WebSites\AJAXEnabledWebSite1\admin\clientPMP.aspx.vb:25
    System.Web.UI.Control.OnLoad(EventArgs e) +80
    System.Web.UI.Control.LoadRecursive() +49
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3748


    Please let me know if anyone need more information. Thanks for your time. 

  • Re: FYI: How to make FCKeditor work in an UpdatePanel

    04-18-2007, 1:42 PM
    • Member
      43 point Member
    • jpgarcia
    • Member since 10-20-2006, 11:04 PM
    • Sevilla, España
    • Posts 19

    I suppose your button is inside a repeater.
    if look like this, you need to get the button on the Repeater_ItemDataBound event.

    protected void MyRepeater_ItemDataBound(object sender,
        System.Web.UI.WebControls.RepeaterItemEventArgs e)
    {
        RepeaterItem item = e.Item;
    
        if ((item.ItemType == ListItemType.Item) ||
            (item.ItemType == ListItemType.AlternatingItem))
        {
            (Button)btnSubmit = item.FindControl("btnSubmit");
            btnSubmit.Attributes.Add("onClick", "if (eval('(typeof(MyFCKObject) != \'undefined\');')){MyFCKObject.UpdateEditorFormValue(); return true;}else{return true;}");
        }
    }

     

    Hope it helps

    Juan Pablo GarcĂ­a
    Blog: www.computerapia.com
  • Re: FYI: How to make FCKeditor work in an UpdatePanel

    04-18-2007, 5:02 PM
    • Member
      12 point Member
    • astrokid
    • Member since 04-18-2007, 12:31 AM
    • Posts 8

    I guess the problem is somehow I can't find the control in the child repeater.

     Here is a simple example

     

    1        Protected Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
    2            If e.Item.ItemType = ListItemType.Item Then
    3                Dim SubRepeater As Repeater = sender
    4                Dim editbutton As Button = SubRepeater.FindControl("Button1")
    5                editbutton.Text = "dfsadfs"
    6            End If
    7        End Sub
    8    End Class
     
    The error is on line 5 "System.NullReferenceException: Object reference not set to an instance of an object"
    Is anyone have any suggestion about how I can find control in the child repeater?
    Thanks 
     
     
  • Re: FYI: How to make FCKeditor work in an UpdatePanel

    04-18-2007, 5:11 PM
    • Member
      69 point Member
    • joshcoady
    • Member since 02-16-2006, 8:48 PM
    • Rohnert Park, CA
    • Posts 30

    Is the ID of your repeater Repeater1 or SubRepeater?

    Try using e.Item.FindControl instead.

    If you still cant get it to work, please also post your repeater declaration from your aspx os ascx. (The part that starts with <asp:repeater and ends with </asp:repeater>.)

  • Re: FYI: How to make FCKeditor work in an UpdatePanel

    04-18-2007, 5:28 PM
    • Member
      12 point Member
    • astrokid
    • Member since 04-18-2007, 12:31 AM
    • Posts 8

    Here is the code from aspx

     

     

    1    <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
    2            <ItemTemplate>
    3                <ul>
    4                <li>
    5                    <asp:Repeater ID="Repeater2" runat="server" DataSourceID="SqlDataSource1">
    6                        <ItemTemplate>
    7                        <ul>
    8                        <li> <asp:Button ID="Button1" runat="server" Text="Button" /></li>
    9                        </ul>
    10                          
    11                       </ItemTemplate>
    12                   </asp:Repeater>
    13               </li>
    14               </ul>
    15               </ItemTemplate>
    16               </asp:Repeater>
     
    Thanks 
      
  • Re: FYI: How to make FCKeditor work in an UpdatePanel

    04-18-2007, 6:52 PM
    • Member
      69 point Member
    • joshcoady
    • Member since 02-16-2006, 8:48 PM
    • Rohnert Park, CA
    • Posts 30
    Ok, so you need to be handling the ItemDataBound event from the repeater that directly contains the button. In this case it is Repeater2. Then you can use e.Item.FindControl("Button1") to get at the button.
Page 2 of 5 (61 items) < Previous 1 2 3 4 5 Next >