1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Comment post problem

Comment post problem

4 posts, 1 answered
  1. Muhammad Saqib
    Muhammad Saqib avatar
    95 posts
    Registered:
    09 Sep 2009
    16 Nov 2009
    Link to this post
    Hi,

    I have relatively serious issue. When ever some one post comments in any of Blog Post, The page refreshes, so by chance if user hits the "refresh" of F5 button on browser, the same comment is posted again.
    How i restrict it not to post the same comment again even user hits the refresh button.

    Secondly can i add Update panel to my comment list. i.e when ever any one posts the comment  the comment list is updated without page refresh.
    I tried adding Update Panel into "SingleViewContentItem.ascx" file but after submitting Comment , the list is not updated, when i refreshes the page, then comment shows up in the list.

    Please help me in resolving my issue first!
    Thanks,
    Best Regards.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    16 Nov 2009
    Link to this post
    Hello Muhammad Saqib,

    This is a browser problem. When you refresh a web page, browser re-create last event that was made by an user on a page content. To avoid submitting the data you need to  check posted data every time.
    You can keep one object for the web browser - hidden field or view state and another object on the server as session. On each request, have to verify if the objects' value. If they are the same - request is generated by an user request. If they are different, the request is generated by page refresh or page reload method of the browser.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Muhammad Saqib
    Muhammad Saqib avatar
    95 posts
    Registered:
    09 Sep 2009
    17 Nov 2009
    Link to this post
    What if i want to override the comment save button event.?
    actually i want to post comment via ajax (using UpdatePanel). so i want whenever user posts any comment it shows up in the list right away. for now when i use update panel, the comment list did'nt update automatically.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    17 Nov 2009
    Link to this post
    Hi Muhammad Saqib,

    Then you need to override comments list control to access the button and its event. You need to replace the default comments list control declared in ListPageDetail.ascx template.

    Sample code:

    namespace Telerik.Samples
    {
        public class CustomComments : CommentsList
        {
            public CustomComments()
            {
     
            }
     
            public override string LayoutTemplatePath
            {
                get
                {
     
                    return "~/Sitefinity/ControlTemplates/Blogs/CommentsList.ascx";
                }
            }
     
            protected override void CreateChildControls()
            {
                base.CreateChildControls();
                SubmitButton.Click += new EventHandler(SubmitButton_Click);
            }
     
            void SubmitButton_Click(object sender, EventArgs e)
            {
                 
            }
     
            
        }
     
    }


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Answered
Register for webinar
4 posts, 1 answered