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

Forums / General Discussions / Ajax Refresh with Sitefinity

Ajax Refresh with Sitefinity

7 posts, 0 answered
  1. Stefano
    Stefano avatar
    29 posts
    Registered:
    14 Jun 2011
    29 Jun 2011
    Link to this post
    Hi,
    I have some pages with the same template and I wish only to update the content and not reload all the pages. Can I use Ajax? If I can could you attach me an example?

    Thank you!

    Stefano
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    30 Jun 2011
    Link to this post
    Hello Stefano,

    Here is a sample code with RadGrid.  I am also sending you a short video.

    using System.Collections.Generic;
    using Telerik.Sitefinity.Web.UI;
    using Telerik.Sitefinity.Modules.Pages.Web.UI;
    using Telerik.Sitefinity.Web.UI.PublicControls.BrowseAndEdit;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web;
    using Telerik.Sitefinity.Web;
    using Telerik.Sitefinity.Modules.Pages;
    using Telerik.Sitefinity.Pages.Model;
    using System.Linq;
    using System;
    using Telerik.Web.UI;
    using System.Web.Security;
    using Telerik.Sitefinity.Security;
    using Telerik.Sitefinity.Modules.Forms;
    using System.Collections;
    using Telerik.Sitefinity.Fluent.Pages;
    using Telerik.Sitefinity.Modules.UserProfiles;
    using Telerik.Sitefinity.Security.Model;
    using Telerik.Sitefinity.Taxonomies.Data;
    using Telerik.Sitefinity.Taxonomies;
    using Telerik.Sitefinity.Taxonomies.Model;
    using Telerik.Sitefinity.GenericContent.Model;
    using Telerik.Sitefinity.Blogs.Model;
    using Telerik.Sitefinity.Modules.GenericContent.Web.UI;
    using Telerik.Sitefinity.Samples1;
     
     
    namespace Telerik.Sitefinity.Samples
    {
        [RequireScriptManager]
        public class SimpleViewCustom : SimpleView
        {
     
            public override string LayoutTemplatePath
            {
                get
                {
                    return layoutTemplatePath;
                }
                 
            }
     
            protected override string LayoutTemplateName
            {
                get
                {
                    return null;
                }
            }
            protected override void InitializeControls(GenericContainer container)
            {
     
                RadGrid1.ItemCommand += new Telerik.Web.UI.GridCommandEventHandler(RadGrid1_ItemCommand);
                RadGrid1.NeedDataSource += new GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource);
               
            }
     
            void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
            {
                var grid = sender as RadGrid;
                grid.DataSource = CreateDataSource();
            }
     
            void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
            {
                if (e.CommandName == "Edit")
                {
                }
     
                if (e.CommandName == "Delete")
                {
     
                }
     
                if (e.CommandName == "InitInsert")
                {
                }
            }
     
            protected virtual IList<DataSourceFake> CreateDataSource()
            {
     
                var fake = new List<DataSourceFake>();
                for (int i = 0; i < 100; i++)
                {
                    fake.Add(new DataSourceFake(i.ToString(), i.ToString(), i.ToString(), i, i, i, i, i));
                }
                return fake;
            }
     
            protected virtual RadGrid RadGrid1
            {
                get
                {
                    return this.Container.GetControl<RadGrid>("RadGrid1", true);
                }
     
            }
     
     
            private Sitefinity.Web.UI.PublicControls.BrowseAndEdit.BrowseAndEditToolbar browseAndEditToolbar;
            private List<BrowseAndEditCommand> commands = new List<BrowseAndEditCommand>();
            private const string layoutTemplatePath = "~/SfSamples/Telerik.Sitefinity.Samples1.Resources.SimpleViewCustomTemplate.ascx";
            private Guid randomGuid = Guid.Empty;
       
         
        }
     
        public class DataSourceFake
        {
     
            public DataSourceFake(string _longname, string _commonNameDesc, string _containersOrdered, int _price, int _extPrice, int _quoteID, int _lineID, int _enteredByContactID)
            {
                longname = _longname;
                commonNameDesc = _commonNameDesc;
                containersOrdered = _containersOrdered;
                price = _price;
                extPrice = _extPrice;
                quoteID = _quoteID;
                lineID = _lineID;
                enteredByContactID = _enteredByContactID;
            }
     
            public int quoteID
            {
                get;
                set;
            }
            public string longname
            {
                get;
                set;
            }
            public string commonNameDesc
            {
                get;
                set;
            }
            public string containersOrdered
            {
                get;
                set;
            }
            public int price
            {
                get;
                set;
            }
            public int extPrice
            {
                get;
                set;
            }
            public int lineID
            {
                get;
                set;
            }
            public int enteredByContactID
            {
                get;
                set;
            }
     
     
        }
    }


    control template

    <telerik:RadGrid ID="RadGrid1" runat="server"  AllowPaging="true" PageSize="20" AutoGenerateDeleteColumn="True"  EnableViewState="true"
        AutoGenerateEditColumn="True" CellSpacing="0" GridLines="None" Skin="Sitefinity">
    <MasterTableView AutoGenerateColumns="False" DataKeyNames="quoteID,lineID,enteredByContactID">
    <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
     
    <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
    <HeaderStyle Width="20px"></HeaderStyle>
    </RowIndicatorColumn>
     
    <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
    <HeaderStyle Width="20px"></HeaderStyle>
    </ExpandCollapseColumn>
     
        <Columns>
            <telerik:GridBoundColumn DataField="longname"
                FilterControlAltText="Filter longname column" HeaderText="longname"
                SortExpression="longname" UniqueName="longname">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="commonNameDesc"
                FilterControlAltText="Filter commonNameDesc column" HeaderText="commonNameDesc"
                SortExpression="commonNameDesc" UniqueName="commonNameDesc">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="containersOrdered"
                FilterControlAltText="Filter containersOrdered column"
                HeaderText="containersOrdered" SortExpression="containersOrdered"
                UniqueName="containersOrdered">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="price"
                FilterControlAltText="Filter price column" HeaderText="price" ReadOnly="True"
                SortExpression="price" UniqueName="price">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="extPrice"
                FilterControlAltText="Filter extPrice column" HeaderText="extPrice"
                ReadOnly="True" SortExpression="extPrice" UniqueName="extPrice">
            </telerik:GridBoundColumn>
        </Columns>
     
    <EditFormSettings>
    <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
    </EditFormSettings>
    </MasterTableView>
     
    <FilterMenu EnableImageSprites="False"></FilterMenu>
     
    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
    </telerik:RadGrid>


    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Stefano
    Stefano avatar
    29 posts
    Registered:
    14 Jun 2011
    04 Jul 2011
    Link to this post
    I see the video but I want change the page also I need only a panel that refresh only and not reload the page because the template is the same for all the pages.

    Stefano
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    04 Jul 2011
    Link to this post
    Hello Stefano,

    When you use RadAjaxManagerProxy and set AjaxSetting you will not reload the entire page, but only the control that is being modified will trigger the RadAjaxLoadingPanel.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Stefano
    Stefano avatar
    29 posts
    Registered:
    14 Jun 2011
    06 Jul 2011
    Link to this post
    Maybe I'm wrong to explained. I have, for example, 2 pages with the same template(masterpage); the template is divided in 2 ContentPlaceholder: there is a common navigation menu for different pages. When i click on the menu to change into a different page Can I use Ajax to refresh only the content of the next page (the content can be an image or text). Everytime that i want to access a new page i want to load just an specific element of the body page . Could you please send me an example or some guidelines ?
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    06 Jul 2011
    Link to this post
    Hi Stefano,

    You can use an iframe to do this or some control that shows the data that comes from a data storage and it is specific to a given page- standard ajax update of a control

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Stefano
    Stefano avatar
    29 posts
    Registered:
    14 Jun 2011
    06 Jul 2011
    Link to this post
    How can I use the Iframe? I put the Iframe on the ContentPlaceHolder but it doesn't work...I don't understand what you mean about the second solution. Can you give me more details?
7 posts, 0 answered