FreeTextBox

The no. 1 free ASP.NET HTML Editor.
Welcome to FreeTextBox Sign in | Join | Help

OnSaveClick not available during dynamic creation of FTB

  •  10-08-2005, 3:11 PM

    OnSaveClick not available during dynamic creation of FTB

    I just did some testing using the v3.1 and found that you cannot set the OnSaveClick property when creating the control dynamically.  The propery exists in the Design Time control and functions properly but when you want to create the control programmatically it does not appear in the intellisense.  If you try to specify it anyway the following error message is displayed when you compile the code:

    'FreeTextBoxControls.FreeTextBox.OnSaveClick(System.EventArgs)' is inaccessible due to its protection level.


    The test consisted of the following

    Web Page:

    <%@PageLanguage="C#"MasterPageFile="~/Default.master"Title="Managing | Home Page Content"CodeFile="Content_FTB_simple.aspx.cs"Inherits="Admin_Content"ValidateRequest="false"%>

    <%@RegisterTagPrefix="ftb"Namespace="FreeTextBoxControls"Assembly="FreeTextBox" %>

    <asp:Contentid="ContentContent"ContentPlaceHolderid="Main"runat="server">

    <div>

    <asp:PlaceHolderID="ftbPlaceHolder"runat="server"></asp:PlaceHolder>

    </div>

    </asp:Content>

    Page_Load:
     

        protectedvoid Page_Load(object sender, EventArgs e)

        {

            if (!IsPostBack)

            {

            // Create the dynamic FTB  using the placeholder

            FreeTextBox ftb = newFreeTextBox();

            ftb.ID = "dynamicFTB";

            // this solves the problem with the default location of data

            ftb.SupportFolder = "~/FtbWebResource.axd";

           

            // Add content from SQL Server data

            int textId = 0;

            lcp = newList<ContentPage>();

            lcp = ContentManager.GetContent(textId);

            ftb.Text = lcp[0].Welcome;

     

            // Create the Save button

            Save tbbSave = newSave();

            // Create a new Toolbar

            Toolbar tb = newToolbar();

            // Add the Save button to the new toolbar

            tb.Items.Add(tbbSave);

            // Add the new toolbar to the FTB

            ftb.Toolbars.Add(tb);

            // Add the FTB to the placeholder

            ftbPlaceHolder.Controls.Add(ftb);

            }

        }



    The control is created and displayed and all buttons work except the Save button.  When the Save button is clicked the page is posted back but the control is lost. It does not survive the postback.  I tried explicitly setting the EnableViewState property to true but that has no effect. 

    I inspected the Controls on postback iterating through all of them but found that the ftbPlaceHolder has no child controls so the ftb control is lost.  I thought at first that this might be related to the Master/Content Placeholder environment so I created a new web page that does not use the ContentPlaceHolder object.  The behaviour is the same.

    I'm beginning to wonder if this control was tested at all.  I really like this control and am willing to assist in debugging it but it should not have been released in this state.  It should have been presented as a beta and our assistance solicited so that those who do not have the time or inclination to assist do not waste their time.

    Please tell us which version is the latest truly functional one.  Is there any current version intended to work with ASP.NET 2.0 that works in anything but the most trivial way?



    Ron Cicotte
    Summer Street Systems
View Complete Thread
www.freetextbox.com