Hi there,
I have searched high and low for an answer to this, however can't seem to get any of them working, so here goes...
I have a WebForm with a single RadGrid Q3 2009 and a RadAjaxManager control. The RadGrid has AllowFilteringByColumn enabled. The WebForm has a MasterPage, which has RadScriptManager and a RadAjaxLoadingPanel. In the RadGrid, one of my columns is an ImageButton GridButtonColumn (with RadWindow Confirm). In the RadGrid1_ItemDataBound I set the CommandArgument of the button. In RadGrid1_ItemCreated, I use Master.FindControl to find the RadScriptManager, and call .RegisterPostBackControl(button). This causes the ImageButton to create a full PostBack as expected.
The problem is that this stops working after an AsyncPostBack has occurred. For instance, when the RadGrid is filtered on any column, an AsyncPostBack occurs. If I click on the same button which caused a full PostBack before, it now causes another AsyncPostBack which I do not want. I'd really appreciate any help, I have put together a simple WebSite project to demonstrate this, which I will email if you need it.
Essentially, the important code is as follows:
Master Page:
WebForm:
Code-Behind:
I have tried adding the __doPostBack(...) Javascript call on to the ImageButton instance per the solution in this post http://www.telerik.com/help/aspnet-ajax/ajxexclude.html, but that didn't work for me. I have tried using a regular ScriptManager instead of the RadScriptManager too, to no avail.
Many thanks,
Anthony
I have searched high and low for an answer to this, however can't seem to get any of them working, so here goes...
I have a WebForm with a single RadGrid Q3 2009 and a RadAjaxManager control. The RadGrid has AllowFilteringByColumn enabled. The WebForm has a MasterPage, which has RadScriptManager and a RadAjaxLoadingPanel. In the RadGrid, one of my columns is an ImageButton GridButtonColumn (with RadWindow Confirm). In the RadGrid1_ItemDataBound I set the CommandArgument of the button. In RadGrid1_ItemCreated, I use Master.FindControl to find the RadScriptManager, and call .RegisterPostBackControl(button). This causes the ImageButton to create a full PostBack as expected.
The problem is that this stops working after an AsyncPostBack has occurred. For instance, when the RadGrid is filtered on any column, an AsyncPostBack occurs. If I click on the same button which caused a full PostBack before, it now causes another AsyncPostBack which I do not want. I'd really appreciate any help, I have put together a simple WebSite project to demonstrate this, which I will email if you need it.
Essentially, the important code is as follows:
Master Page:
| <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %> |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head runat="server"> |
| <title></title> |
| <asp:ContentPlaceHolder id="head" runat="server"> |
| </asp:ContentPlaceHolder> |
| </head> |
| <body> |
| <form id="form1" runat="server"> |
| <div> |
| <asp:ScriptManager ID="ScriptManager1" runat="server" /> |
| <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" > |
| <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' style="border:0;" /> |
| </telerik:RadAjaxLoadingPanel> |
| <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"> |
| </asp:ContentPlaceHolder> |
| </div> |
| </form> |
| </body> |
| </html> |
WebForm:
| <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
| <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> |
| </asp:Content> |
| <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> |
| <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> |
| <AjaxSettings> |
| <telerik:AjaxSetting AjaxControlID="RadGrid1"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> |
| <telerik:AjaxUpdatedControl ControlID="RadWindowManager1" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| </AjaxSettings> |
| </telerik:RadAjaxManager> |
| <telerik:RadGrid ID="RadGrid1" runat="server" |
| AllowPaging="True" |
| VirtualItemCount="100" |
| datasourceid="ObjectDataSource1" |
| GridLines="None" |
| Skin="Windows7" |
| AllowFilteringByColumn="True" |
| EnableLinqExpressions="false" |
| onitemcommand="RadGrid1_ItemCommand" |
| onitemcreated="RadGrid1_ItemCreated" |
| onitemdatabound="RadGrid1_ItemDataBound"> |
| <GroupingSettings CaseSensitive="false" /> |
| <MasterTableView autogeneratecolumns="False" DataKeyNames="ID" > |
| <PagerStyle AlwaysVisible="true" /> |
| <Columns> |
| <telerik:GridButtonColumn ConfirmText="View this item?" ConfirmDialogType="RadWindow" |
| ConfirmTitle="View Item" ButtonType="ImageButton" CommandName="View" Text="View" |
| UniqueName="ViewColumn" ItemStyle-Width="15px" ImageUrl="~/Images/newContact.gif"> |
| </telerik:GridButtonColumn> |
| <telerik:GridBoundColumn DataField="Name" HeaderText="Name" |
| SortExpression="Name" UniqueName="Name" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| </MasterTableView> |
| <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle> |
| </telerik:RadGrid> |
| <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" |
| EnablePaging="true" |
| DataObjectTypeName="Title" |
| OldValuesParameterFormatString="original_{0}" |
| SelectMethod="GetTitles" |
| SelectCountMethod="GetTitlesCount" |
| TypeName="DataAccess"> |
| </asp:ObjectDataSource> |
| <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager> |
| <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> |
| </asp:Content> |
Code-Behind:
| 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; |
| public partial class _Default : System.Web.UI.Page |
| { |
| protected void Page_Load(object sender, EventArgs e) |
| { |
| } |
| protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) |
| { |
| string commandname = e.CommandName; |
| string commandArgument = e.CommandArgument.ToString(); |
| if (commandname.Equals("View") && !string.IsNullOrEmpty(commandArgument)) |
| { |
| int id = int.Parse(commandArgument); |
| Label1.Text = "You clicked item id: " + id.ToString(); |
| } |
| } |
| protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) |
| { |
| // make the View ImageButtons PostBackControls |
| if (e.Item is GridDataItem) |
| { |
| GridDataItem item = (GridDataItem)e.Item; |
| ImageButton viewButton = (ImageButton)item["ViewColumn"].Controls[0]; |
| ScriptManager.GetCurrent(Page).RegisterPostBackControl(viewButton); |
| //viewButton.Attributes.Add("onclick", string.Format("realPostBack(\"{0}\", \"\"); return false;", viewButton.UniqueID)); |
| //viewButton.OnClientClick = String.Format("{0}.__doPostBack(\"{1}\",\"{2}\");return false;", RadGrid1.ClientID, viewButton.UniqueID, viewButton.CommandArgument); |
| //RadScriptManager rsm = Master.FindControl("RadScriptManager1") as RadScriptManager; |
| //if (rsm != null) |
| //{ |
| // rsm.RegisterPostBackControl(viewButton); |
| //} |
| } |
| } |
| protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) |
| { |
| if (e.Item is GridDataItem) |
| { |
| GridDataItem item = (GridDataItem)e.Item; |
| (item["ViewColumn"].Controls[0] as ImageButton).CommandArgument = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"].ToString(); ; |
| } |
| } |
| } |
I have tried adding the __doPostBack(...) Javascript call on to the ImageButton instance per the solution in this post http://www.telerik.com/help/aspnet-ajax/ajxexclude.html, but that didn't work for me. I have tried using a regular ScriptManager instead of the RadScriptManager too, to no avail.
Many thanks,
Anthony
