More in this section

Forums / Developing with Sitefinity / CommentsListExtender


2 posts, 0 answered
  1. Jackson
    Jackson avatar
    51 posts
    23 May 2008
    17 Oct 2008
    Link to this post
    I have created a class which extends commentslist so that I may require users to login before they comment. I recently upgrade to sitefinity 3.5 and now when I try to use the custom class with code such as

    ((Button)this.Container.FindControl("submitBtn")).Enabled = false;

    It returns an error stating that the control cannot be found.  or what it basically says is 

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

    Any advice?

  2. Pepi
    Pepi avatar
    981 posts
    31 Jan 2017
    20 Oct 2008
    Link to this post
    Hello Chris,

    You could try the following code to access the submit button:

    public class CommentsListExtender : CommentsList 
            protected override void CreateChildControls() 
                if (this.Page == null
                    this.Page = new Page(); 
                if (!this.Page.User.Identity.IsAuthenticated) 
                    ((Button)this.Container.SubmitButton).Enabled = false

    Also, make sure the corresponding template contains a button with ID "submitBtn".

    Do let us know how it goes.

    Best wishes,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
2 posts, 0 answered