Ajax Refresh with Sitefinity

Posted by Community Admin on 03-Aug-2018 16:18

Ajax Refresh with Sitefinity

All Replies

Posted by Community Admin on 29-Jun-2011 00:00

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

Posted by Community Admin on 30-Jun-2011 00:00

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

Posted by Community Admin on 04-Jul-2011 00:00

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

Posted by Community Admin on 04-Jul-2011 00:00

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

Posted by Community Admin on 06-Jul-2011 00:00

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 ?

Posted by Community Admin on 06-Jul-2011 00:00

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

Posted by Community Admin on 06-Jul-2011 00:00

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?

This thread is closed