More in this section

Forums / Developing with Sitefinity / MS AJAX - possible solution

MS AJAX - possible solution

2 posts, 0 answered
  1. Chris
    Chris avatar
    9 posts
    Registered:
    17 Aug 2007
    27 Aug 2008
    Link to this post

    Hi Everyone,

    I posted this when I was searching for a solution to using MS AjAX Update Panels in Sitefinity.  Just noticed the thread was retired so thought I would share here.

    Old thread http://www.sitefinity.com/support/forums/support-forum-thread/b1043S-thbmc.aspx

    After some experimentation I have come up with an alternative solution to using Ajax Update panels in Sitefinity. It might not be ideal for everyone but I thought it might be worth sharing.

    First I created my UserControl with Ajax Update Panel functionality in the standard way.

    Then I created a second UserControl to upload to Sitefinity. This control has nothing but a single PlaceHolder control in the ascx. In the code behind I added the following...

    string pageMode = base.Request.QueryString["cmspagemode"];

    if (!string.IsNullOrEmpty(pageMode) && (pageMode == "edit" || pageMode == "preview"))
    {
    // we are in Sitefinity's backend
    // you could load in a message or dummy control

    }
    else
    {

    Control QuickSearchUserControl = LoadControl("~/UserControls/Custom/QuickSearchFrontend.ascx");
    ControlPlaceHolder.Controls.Add(QuickSearchUserControl);
    }

    Basically it detects if you are in the Sitefinity backend using the QueryString "cmspagemode". If we are in the backend don't load the control with the Ajax Update Panel (as it causes issues when editing in sitefinity). If we aren’t load the control as normal.

    This could easily be extended into a control with a property for the path to the UserControl to load in and maybe a second property for a message to show in when in the backend of Sitefinity. That way it could be reused across a Sitefinity Site and the path / message properties could be set in the Sitefinity UI.

    Hope this is of some use to you

    Thanks

    Chris

  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    29 Aug 2008
    Link to this post
    Hello Chris,

    Just a bit more elegant code for the same checks:

    private bool IsPageInAdmin() 
      // will return TRUE is the page is viewed in administration part 
      if (this.Page is Telerik.Cms.Web.PreviewPage) 
         return true
      // will return TRUE is the page is in editing mode 
      if (this.Page is Telerik.Cms.Web.EditPage) 
         return true
      // the page is viewed in the public part  
      if (this.Page is Telerik.Cms.Web.InternalPage) 
         return false

    As I mentioned in the other thread, this will be definitely helpful for someone.

    Regards,
    Georgi
    the Telerik team

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