This is a migrated thread and some comments may be shown as answers.

I can not use RadButton of PostbackUrl at RadAjaxPanel or RadAjaxManager + RadButton

5 Answers 43 Views
Grid
This is a migrated thread and some comments may be shown as answers.
小章
Top achievements
Rank 1
小章 asked on 21 Aug 2015, 03:02 AM

When I use 'telerik:RadButton' of PostUrl ,Do not change page.

I only use 'asp:Button'

Now I need use 'telerik:RadButton'. What should I do ?

@E1.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="E1.aspx.cs" Inherits="THS.ERP.MM.UI.SurveyTest.E1" %>
 
<!DOCTYPE html>
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
                <Scripts>
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
                </Scripts>
            </telerik:RadScriptManager>
 
            <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>
            <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1"></telerik:RadAjaxLoadingPanel>
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" UpdatePanelsRenderMode="Inline">
                <AjaxSettings>
                    <%-- <telerik:AjaxSetting AjaxControlID="Master_RadGrid">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="Master_RadGrid" LoadingPanelID="RadAjaxLoadingPanel1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>--%>
                </AjaxSettings>
            </telerik:RadAjaxManager>
            <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="100%" Width="100%" LoadingPanelID="RadAjaxLoadingPanel1">
                <telerik:RadGrid ID="Master_RadGrid" runat="server" Width="100%" Height="100%"
                    AllowFilteringByColumn="True"
                    AllowPaging="True"
                    AllowSorting="True"
                    AllowCustomPaging="True"
                    AutoGenerateColumns="False"
                    GroupPanelPosition="Top"
                    OnItemCommand="Master_RadGrid_ItemCommand"
                    OnNeedDataSource="Master_RadGrid_NeedDataSource">
                    <MasterTableView CommandItemDisplay="TopAndBottom"
                        ClientDataKeyNames="Id"
                        EditMode="PopUp"
                        DataKeyNames="Id"
                        ItemType="THS.ERP.MM.UI.SurveyTest.Account">
 
                        <CommandItemTemplate>
                            <div style="padding: 5px 5px;">
                                <asp:LinkButton ID="AddRecord_LinkButton" runat="server" CommandName="AddCommand" PostBackUrl="~/Setup/MaterialE2.aspx">
                    <img style="border: 0px; vertical-align: middle;" alt="" src="/Images/Grid/AddRecord.gif" /> 新增
                                </asp:LinkButton>  
                            </div>
                        </CommandItemTemplate>
                        <Columns>
 
                            <telerik:GridTemplateColumn AllowFiltering="false" AllowSorting="false">
                                <ItemTemplate>
                                    <telerik:RadButton ID="Button1" runat="server" Text="Browse"
                                        ToolTip="Browse"
                                        CommandName="BrowseCommand"
                                        CommandArgument="<%# Item.Id %>"
                                        PostBackUrl="~/SurveyTest/at telerik forum question/E2.aspx">
                                    </telerik:RadButton>
 
                                    <asp:Button ID="ReadRecord_Button" runat="server" Text="Browse"
                                        ToolTip="Browse"
                                        CommandName="BrowseCommand"
                                        CommandArgument="<%# Item.Id %>"
                                        PostBackUrl="~/SurveyTest/at telerik forum question/E2.aspx" />
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn AllowFiltering="false" AllowSorting="false">
                                <ItemTemplate>
                                    <asp:Button ID="EditRecord_Button" runat="server" Text="Edit"
                                        ToolTip="Edit"
                                        CommandName="EditCommand"
                                        PostBackUrl="~/SurveyTest/at telerik forum question/E2.aspx" />
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn DataField="Id" Visible="false">
                                <ItemTemplate>
                                    <asp:HiddenField ID="MaterialUid_Id" runat="server" Value="<%# BindItem.Id %>" />
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:HiddenField ID="MaterialUid_Id" runat="server" Value="<%# BindItem.Id %>" />
                                </EditItemTemplate>
                            </telerik:GridTemplateColumn>
 
                            <telerik:GridBoundColumn DataField="Name" HeaderText="Name">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Age" HeaderText="Age">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="CreateUserId" HeaderText="CreateUserId">
                            </telerik:GridBoundColumn>
                            <telerik:GridDateTimeColumn DataField="CreateDateTime" HeaderText="CreateDateTime">
                            </telerik:GridDateTimeColumn>
                            <telerik:GridTemplateColumn AllowFiltering="false" AllowSorting="false" UniqueName="DeleteColumn">
                                <ItemTemplate>
                                    <telerik:RadButton ID="DeleteRecord_Button" runat="server"
                                        ToolTip="刪除"
                                        CssClass="DeleteCommand"
                                        CommandName="DeleteCommand"
                                        CommandArgument="<%# Item.Id %>">
                                        <Image EnableImageButton="true" />
                                    </telerik:RadButton>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                        </Columns>
                        <PagerStyle PageSizes="10,20,30,50,100"></PagerStyle>
                        <CommandItemSettings ShowAddNewRecordButton="true" ShowRefreshButton="False" AddNewRecordText="新增"></CommandItemSettings>
                        <NoRecordsTemplate>找不到資料!!</NoRecordsTemplate>
                    </MasterTableView>
                    <ClientSettings EnableRowHoverStyle="true" AllowColumnsReorder="True">
                        <Selecting AllowRowSelect="True"></Selecting>
                        <%--<ClientEvents OnCommand="OnCommand" OnColumnClick="ColumnClick" />--%>
                    </ClientSettings>
                </telerik:RadGrid>
            </telerik:RadAjaxPanel>
        </div>
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                function AttachDownloadOnClientClick(sender) {
                    $find("<%= RadAjaxManager1.ClientID %>").__doPostBack(sender.name, "");
                    //do not poskback
                    return false;
                }
 
                function confirmCallBackFn(arg) {
                    var ajaxManager = $find("<%=RadAjaxManager1.ClientID%>");
                    if (arg) {
                        ajaxManager.ajaxRequest('ok');
                    }
                    else {
                        ajaxManager.ajaxRequest('cancel');
                    }
                }
 
                function OnRequestStart(ajaxControl, eventArgs) {
                    $find("<%= RadAjaxManager1.ClientID %>").__doPostBack(sender.name, "");
 
                    var eventTarget = eventArgs.get_eventTarget();
                <%--if (eventTarget == "<%= ImageButton1.UniqueID %>") {
                    return confirm('Are you sure?');
                }
                else {
                    return false;
                }--%>
                }
            </script>
        </telerik:RadCodeBlock>
    </form>
</body>
</html>

 

@E1.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using THS.ERP.MM.Model.ViewModel;
 
namespace THS.ERP.MM.UI.SurveyTest
{
    public partial class E1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
 
        private IEnumerable<Account> s_Accounts;
 
        protected void Master_RadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            if (s_Accounts == null)
            {
                s_Accounts = new List<Account>()
                {
                    new Account(){Id = Guid.NewGuid(),Name = "yao",Age = 18,CreateDateTime = DateTime.Now,CreateUserId = "SYS"}
                };
            }
            if (!e.IsFromDetailTable)
            {
                var radGrid = (RadGrid)sender;
 
                var itemCount = s_Accounts.Count();
                IEnumerable<Account> queryResults = s_Accounts;
 
                if (e.RebindReason == GridRebindReason.InitialLoad || e.RebindReason == GridRebindReason.ExplicitRebind)
                {
                    radGrid.VirtualItemCount = itemCount;
                }
 
                radGrid.DataSource = queryResults;
            }
        }
 
        public object CommandArgument { get; set; }
        public string CommandName { get; set; }
 
        protected void Master_RadGrid_ItemCommand(object sender, GridCommandEventArgs e)
        {
            this.CommandArgument = e.CommandArgument;
            this.CommandName = e.CommandName;
        }
    }
 
    public class Account
    {
        public Guid Id { get; set; }
        public string Name { get; set; }
        public int Age { get; set; }
        public DateTime CreateDateTime { get; set; }
        public string CreateUserId { get; set; }
    }
}

 

@E2.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="E2.aspx.cs" Inherits="THS.ERP.MM.UI.SurveyTest.at_telerik_forum_question.E2" %>
 
<%@ PreviousPageType VirtualPath="~/SurveyTest/at telerik forum question/E1.aspx" %>
 
<!DOCTYPE html>
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            I at E2.aspx
        </div>
    </form>
</body>
</html>

 

@E2.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace THS.ERP.MM.UI.SurveyTest.at_telerik_forum_question
{
    public partial class E2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsPostBack)
            {
                return;
            }
            if (this.PreviousPage == null)
            {
                this.Response.Redirect("E1.aspx");
            }
            if (!this.PreviousPage.IsCrossPagePostBack)
            {
                this.Response.Redirect("E1.aspx");
            }
 
            this.Response.Write(string.Format("Name:{0},Argument:{1}", this.PreviousPage.CommandName, this.PreviousPage.CommandArgument));
        }
    }
}

5 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 25 Aug 2015, 08:44 AM
Hi,

Could you temporarily disable any AJAX on the page if present (RadAjaxManager, RadAjaxPanel, UpdatePanel, etc.) and enable your script debugger (FireBug or F12) to see whether there are any script or server errors interfering?

Does the RadButton work if you remove the confirmation logic? I suggest that you examine the following live sample, which demonstrates how you can achieve confirmation using RadButton:
http://demos.telerik.com/aspnet-ajax-beta/button/examples/confirm/defaultcs.aspx


Hope this helps.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
小章
Top achievements
Rank 1
answered on 27 Aug 2015, 03:25 AM
[quote]Eyup said:Hi,

Could you temporarily disable any AJAX on the page if present (RadAjaxManager, RadAjaxPanel, UpdatePanel, etc.) and enable your script debugger (FireBug or F12) to see whether there are any script or server errors interfering?

Does the RadButton work if you remove the confirmation logic? I suggest that you examine the following live sample, which demonstrates how you can achieve confirmation using RadButton:
http://demos.telerik.com/aspnet-ajax-beta/button/examples/confirm/defaultcs.aspx


Hope this helps.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items

[/quote]

 Hi,

My question is 'PostbackUrl' block, It is no confirm logic.

<telerik:RadButton ID="Button1" runat="server" Text="Browse"
    ToolTip="Browse"
    CommandName="BrowseCommand"
    CommandArgument="<%# Item.Id %>"
    PostBackUrl="~/SurveyTest/at telerik forum question/E2.aspx">
</telerik:RadButton>

 

0
Eyup
Telerik team
answered on 31 Aug 2015, 11:15 AM
Hi,

In that case I suggest that you create a new very basic web site sample demonstrating the problematic behavior and open a new formal support thread for RadButton to send it to us. Thus, we will be able to reproduce the issue locally and try to determine the cause of the problem.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
小章
Top achievements
Rank 1
answered on 01 Sep 2015, 02:07 AM

Hi,

I already supply full sample, Please copy paste to your project , and run 'Browse RadButton'

0
Accepted
Eyup
Telerik team
answered on 03 Sep 2015, 12:48 PM
Hello,

To resolve the issue, you need to exclude the button when initiating a navigation to another page. Similar to this approach:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/ajaxified-radgrid/what-you-should-have-in-mind/export-from-ajaxified-grid

You can also check the following articles:
http://docs.telerik.com/devtools/aspnet-ajax/controls/ajax/how-to/exclude-controls-from-ajaxifying
http://docs.telerik.com/devtools/aspnet-ajax/controls/ajax/how-to/redirecting-to-another-page

I've created a sample RadGrid web site using the provided code snippets to demonstrate that the suggested approach should work as expected. Please run the attached application and let me know if it helps you.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
小章
Top achievements
Rank 1
Answers by
Eyup
Telerik team
小章
Top achievements
Rank 1
Share this question
or