How to instantiate CuteEditor in a class file

Last post 02-24-2010, 4:22 PM by MMCD. 4 replies.
Sort Posts: Previous Next
  •  02-24-2010, 2:10 PM 58951

    How to instantiate CuteEditor in a class file

    We need to implement CuteEditor as a custom control in our project, but are finding that it will not render correctly. What is the proper way to do this?
     
      public class CuteEditortextArea : Control
      {
        protected override System.Web.UI.Control OnSetupControls(List<System.Web.UI.Control> controls)
        {
          CuteEditor.Editor rte = new CuteEditor.Editor();
          controls.Add(rte);
          return rte;
        }
      }
     
    We end up with the following error when the page is ran:
     
    Object reference not set to an instance of an object.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    Line 69:       foreach (System.Web.UI.Control control in controls) Line 70:       { Line 71:         control.RenderControl(writer); Line 72:       } Line 73: 
     
  •  02-24-2010, 2:17 PM 58952 in reply to 58951

    Re: How to instantiate CuteEditor in a class file

  •  02-24-2010, 2:54 PM 58955 in reply to 58952

    Re: How to instantiate CuteEditor in a class file

    Thanks, but that doesn't appear to help our situation here. We are overriding the System.Web.UI.Control for each control we use in our application. We are adding each of these to a controls collection then rendering them to an HTMLwriter at runtime.
     
     
    control.cs
          // allow the derived class to create controls to render
          List<System.Web.UI.Control> controls = new List<System.Web.UI.Control>();
          System.Web.UI.Control primaryControl = this.OnSetupControls(controls);
          if (primaryControl != null)
          {
            primaryControl.ID = this.ID;
          }

          // render the controls created in the derived class
          foreach (System.Web.UI.Control control in controls)
          {
            control.RenderControl(writer); <-- Exception occurs here on the CuteEditor class.
          }
     
    CuteEditortextArea.cs
      public class CuteEditortextArea : Control
      {
        protected override System.Web.UI.Control OnSetupControls(List<System.Web.UI.Control> controls)
        {
          CuteEditor.Editor rte = new CuteEditor.Editor();
          rte.AutoConfigure = CuteEditor.AutoConfigure.Full;
          rte.Text = "";
          rte.Height = 200;
          rte.ThemeType = CuteEditor.ThemeType.Office2000;
          rte.Controls.e
          controls.Add(rte);
          return rte;
        }
      }
     
     
  •  02-24-2010, 3:45 PM 58956 in reply to 58955

    Re: How to instantiate CuteEditor in a class file

    Here is the call stack where the CuteEditor control gets a null reference exception
     
    [NullReferenceException: Object reference not set to an instance of an object.]
    CuteEditor.Impl.b..ctor(Type type, String key) +74
    CuteEditor.a.i(HtmlTextWriter A_0) +161
    CuteEditor.Editor.Render(HtmlTextWriter writer) +46
     
    We're programmatically  instantiating the CuteSoft control inside our own controls render method. We are rendering it manually and not adding it to the page via control collections.
  •  02-24-2010, 4:22 PM 58957 in reply to 58956

    Re: How to instantiate CuteEditor in a class file

    Ok, we figured it out. We had the .lic file in the wrong location, hence the null reference exceptions. You might want to add a custom exception to make note of that to the programmer. :-) Thanks for your help.
View as RSS news feed in XML