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

Invalid postback or callback argument exception on first paging with arrows

5 Answers 240 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hans Notelteirs
Top achievements
Rank 1
Hans Notelteirs asked on 06 May 2009, 07:26 AM
The Grid is placed within an ascx file that is loaded within a Sharepoint webpart.
There are 2 webparts on the page. One is for the navigation and the other one contains the grid.
When you select an item on the navigation webpart, we are redirected to the page using window.location.href.
The first time the page is loaded and you press on the arrow in the radgrid to get to the next page, you get an "invalid postback or callback argument exception". if we click on the numbers itself, we don't get the invalid postback exception.

Also the first time we click a control in the radgrid that does a postback, the first postback is always a full postback, from the second one we have partial postbacks.

[ArgumentException: Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.]System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument) +2132728System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) +108System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +32System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746

When you first have a full page postback, you don't get the error. For example when you first sort a column or select a page number.
After that the paging works fine, but the outlining of the columns isn't right anymore.
So my questions are:

- How can I fix the postback or callback argument exception?
- How to make sure the layout isn't broken after using the paging?

Note that we performed the fix for Sharepoint in the init.js related to Ajax submits.

Thanks in advance.

<%@ Register TagPrefix="ajax" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %> 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI, Version=2009.1.402.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" %> 
<ajax:ScriptManagerProxy ID="sm" runat="server"
    <Scripts> 
        <ajax:ScriptReference Path="/_layouts/VMMA.Intranet/js/ProgramSheet.js" /> 
    </Scripts> 
</ajax:ScriptManagerProxy> 
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"  
    DefaultLoadingPanelID="RadAjaxLoadingPanel1"
    <AjaxSettings> 
        <telerik:AjaxSetting AjaxControlID="RadGridActualsPlanning"
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="pnlActualsPlanning"  
                    LoadingPanelID="RadAjaxLoadingPanel1" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
        <telerik:AjaxSetting AjaxControlID="rgInvoice"
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="pnlActualsPlanning"  
                    LoadingPanelID="RadAjaxLoadingPanel1" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
    </AjaxSettings> 
</telerik:RadAjaxManager> 

<asp:Panel ID="pnlActualsPlanning" runat="server" Visible="false"
                <h3> 
                    <asp:Label ID="lblActualsPlanning" runat="server"></asp:Label></h3
                <telerik:RadGrid ID="RadGridActualsPlanning" runat="server" AllowFilteringByColumn="true" 
                    AllowPaging="true" Width="760px" AllowSorting="true" AllowColumnsReorder="True" 
                    PagerStyle-AlwaysVisible="true"
                    <ClientSettings Scrolling-AllowScroll="true" Scrolling-ScrollHeight="100%" Scrolling-UseStaticHeaders="true" 
                        Scrolling-FrozenColumnsCount="2" Resizing-AllowColumnResize="True"
                    </ClientSettings> 
                    <ExportSettings Pdf-PaperSize="A4" Pdf-PageWidth="21cm" Pdf-PageHeight="29cm"
                    </ExportSettings> 
                    <PagerStyle LastPageToolTip="Laatste Pagina" NextPagesToolTip="Volgende Pagina's" 
                        NextPageToolTip="Volgende Pagina" PrevPagesToolTip="Vorige Pagina's" PrevPageToolTip="Vorige Pagina" 
                        PagerTextFormat="{4} &nbsp;Pagina <strong>{0}</strong> van <strong>{1}</strong>, item <strong>{2}</strong> tot <strong>{3}</strong> van de <strong>{5}</strong>." 
                        FirstPageToolTip="Eerste Pagina" /> 
                    <StatusBarSettings LoadingText="Wordt geladen..." ReadyText="Klaar" /> 
                    <MasterTableView AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
                        <Columns> 
                            <telerik:GridBoundColumn DataField="ProductRightsID" SortExpression="ProductRightsID" 
                                HeaderText="BillieID" /> 
                            <telerik:GridBoundColumn DataField="programmatitel" SortExpression="programmatitel" 
                                HeaderText="programmatitel" /> 
                            <telerik:GridBoundColumn DataField="productiejaar" SortExpression="productiejaar" 
                                HeaderText="productiejaar" /> 
                            <telerik:GridBoundColumn DataField="jaargang" SortExpression="jaargang" HeaderText="jaargang" /> 
                            <telerik:GridBoundColumn DataField="episodeTitel" SortExpression="episodeTitel" HeaderText="episodeTitel" /> 
                            <telerik:GridBoundColumn DataField="zender" SortExpression="zender" HeaderText="zender" /> 
                            <telerik:GridBoundColumn DataField="uitzenddag" SortExpression="uitzenddag" HeaderText="uitzenddag" /> 
                            <telerik:GridBoundColumn DataField="uitzenduur" HeaderText="uitzenduur" /> 
                        </Columns> 
                    </MasterTableView> 
                </telerik:RadGrid> 
            </asp:Panel> 




5 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 11 May 2009, 08:16 AM
Hello Hans,

I followed your scenario and prepared a sample project (attached to this post). Please check it out on your end and let me know what differs in your case.

Looking forward your reply,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Hans Notelteirs
Top achievements
Rank 1
answered on 12 May 2009, 05:23 PM
I have traced the problem to the following.
When using Telerik controls in a Sharepoint environment and loading UserControls as Webparts it is important to set the EnsureChildControl in the OnInit method of the webpart.

In the dynamicly loaded usercontrol it is important to bind the data to the grids or any other component of Telerik in the onInit method.
This way all the invalid postback disappear.

 

public class IdeaGrid : WebPart  
    {  
        protected Control userControl;  
        private const string controlId = "ideaGridId";  
 
        protected override void OnInit(System.EventArgs e)  
        {  
            base.OnInit(e);  
            EnsureChildControls();  
        }  
 
        protected override void CreateChildControls()  
        {  
            var userControlPath = @"/_controltemplates/VMMA.Intranet/IdeaGrid.ascx";  
            userControl = Page.LoadControl(userControlPath);  
            userControl.ID = controlId;  
            Controls.Add(userControl);  
        }  
    } 
public class IdeaGrid : UserControl  
    {  
        protected override void OnInit(EventArgs e)  
        {  
            base.OnInit(e);  
              
            // Link Events  
            createBtn.Click += createBtn_Click;  
            conceptMeetingDocGenBtn.Click += conceptMeetingDocGenBtn_Click;  
            pitchPoolDocGenBtn.Click += pitchPoolDocGenBtn_Click;  
 
            RadAjaxManager.GetCurrent(Page).ClientEvents.OnRequestStart = "gridRequestStart";  
        }  
 
        protected override void OnLoad(EventArgs e)  
        {  
            base.OnLoad(e);  
              
            gridOverview.DataSource = GetIdeaSource();  
            gridOverview.DataBind();  
        }  

 

 

 

0
Iana Tsolova
Telerik team
answered on 13 May 2009, 07:32 AM
Hi Hans,

I am happy to hear you have found a solution for your case and thank you for sharing it with the community.

Do not hesitate to write us back if any issues arise.

All the best,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Baktha
Top achievements
Rank 1
answered on 13 Aug 2015, 06:24 AM

Hi,

I am using telerik  Version=2008.2.826.35, i want pagination with page size can you help me

0
Eyup
Telerik team
answered on 18 Aug 2015, 06:51 AM
Hi Baktha,

Please note that the Telerik controls kit is improved in every release, being fortified with new features, faster performance, new controls, easier configuration, more user-friendly and attractive interface, etc. Essentially, our duty is to deliver and provide constantly improving products, which enable the developers using them to provide a better project for their customers, enriched with wide range of functionality and features. In this sense, I strongly suggest that you update to the latest release version of the controls even if your current project does not require you to do so.

As for the original issue, have in mind that the NeedDataSource event is the mandatory way when you need to bind the grid to a programmatic data source in the code-behind. It is important to note that you are not using DataBind() to bind the grid. Performing complex grid operations such as Inserting, Deleting, Updating, Hierarchy relations, Grouping, Exporting, Paging, Sorting, Filtering, etc. require accommodating appropriate database operations.  Therefore, we suggest you to avoid Simple Databinding and strongly recommend the use of more advanced databinding methods, which automatically handle the aforementioned functions:
Declarative DataSource
Programmatic Data Binding


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
Hans Notelteirs
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Hans Notelteirs
Top achievements
Rank 1
Baktha
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or