Custom button: Object reference not set to an instance of an object.

  •  02-11-2005, 11:08 AM

    Custom button: Object reference not set to an instance of an object.

    To add a custom button, I use the following code in the Page_Load of my web form:
    WebControl toolctrl4 = Editor1.CreateCommandButton("send","send.gif","Insert My Custom Text");
    toolctrl4.Attributes["onclick"]="document.Form1.submit();";
    int pos = Editor1.ToolControls.IndexOf("Save")+1;
    Editor1.InsertToolControl(pos,"send",toolctrl4);
    The button works fine on the first view of the page, but when there is a PostBack the page fails:
    Object reference not set to an instance of an object.
    System.NullReferenceException: Object reference not set to an instance of an object.
    ...because of this custom button.
    how do I resolve this problem?
View Complete Thread