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

RadFilterDataFieldEditor and problem with postback

12 Answers 262 Views
Filter
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 06 Mar 2013, 12:27 PM
Hi,

Currently using the 2013.1.220.40 version of Telerik and having a problem. At this point in time, it is not clear whether the issue is with just this version or also with previous versions.

On my page, I have two user controls both inside a radajaxpanel. I have configured it so that the init or page load do not run on the control I do not need it to run on when I have an ajax postback. (i.e. if I want to update the 1st user control, then nothing should be run in the second).

Now, one of the controls on the page has a RadFilter. A filter is set up in codebehind on the page_init. If I just update this particular control, everything works fine. However, if I update a different control, due to the skipping of the filter set up in page_init, I am getting an error... Object reference not set to an instance of an object.

More details of the error are...


System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.Web.UI.RadFilterDataFieldEditor.CreateEditorFrom(RadFilterDataFieldEditor baseEditor)
   at Telerik.Web.UI.RadFilterDataFieldEditorCollection.RetrieveEditorForFieldName(String fieldName)
   at Telerik.Web.UI.RadFilterSingleExpressionItem.SetupFunctionInterface(Control container)
   at Telerik.Web.UI.RadFilterExpressionItem.CreateFunctionalInterface()
   at Telerik.Web.UI.RadFilterExpressionItem.InitializeItem()
   at Telerik.Web.UI.RadFilter.CreateFilterItems()
   at Telerik.Web.UI.RadFilter.CreateControlHierarchy()
   at Telerik.Web.UI.RadFilter.CreateChildControls()
   at System.Web.UI.Control.EnsureChildControls()
   at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
   at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
   at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
   at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
   at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
   at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
   at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
   at System.Web.UI.Page.FindControl(String id)
   at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.HandleError(Exception e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at ASP.site_home_aspx.ProcessRequest(HttpContext context) in c:\Users\David\AppData\Local\Temp\Temporary ASP.NET Files\root\b61e1bf9\22b85fdb\App_Web_4pvgfzv1.0.cs:line 0
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

It seems that the filter is not really handling the postback correctly. It should not run... but why does it appear to be running?

Any help on this issue would be very much appreciated.

Thank you.

12 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 07 Mar 2013, 09:55 AM
I have more information to add to this issue.

While working with the control, I have found another, potentially related issue. However, this issue is distinct in that this happens with just one control on the page.

The user control (in both situations) is a treeview on the left, a splitter bar, on the right is a tab strip with a radgrid in the first tab and a filter in the second which will ulitmately populate a radgrid in the second tab.

I click to the search tab (filter) and enter some text in the available box. I then click to add a new Expression.

I get an error...
Parameter cannot be null or empty. Parameter name: fieldName

The full text of the error is...

System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ArgumentException: Parameter cannot be null or empty.
Parameter name: fieldName
   at Telerik.Web.UI.RadFilterDataFieldEditorCollection.FindEditorForFieldName(String fieldName)
   at Telerik.Web.UI.RadFilterDataFieldEditorCollection.RetrieveEditorForFieldName(String fieldName)
   at Telerik.Web.UI.RadFilterSingleExpressionItem.SetupFunctionInterface(Control container)
   at Telerik.Web.UI.RadFilterExpressionItem.CreateFunctionalInterface()
   at Telerik.Web.UI.RadFilterExpressionItem.InitializeItem()
   at Telerik.Web.UI.RadFilter.CreateFilterItems()
   at Telerik.Web.UI.RadFilter.CreateControlHierarchy()
   at Telerik.Web.UI.RadFilter.CreateChildControls()
   at System.Web.UI.Control.EnsureChildControls()
   at Telerik.Web.UI.RadFilter.EnsureItemsCreated()
   at Telerik.Web.UI.RadFilter.RecreateControl()
   at Telerik.Web.UI.RadFilter.AddChildExpression(RadFilterGroupExpressionItem groupItem, Boolean isGroup)
   at Telerik.Web.UI.RadFilterCommandEventArgs.ExecuteCommand(Object source)
   at Telerik.Web.UI.RadFilter.OnBubbleEvent(Object source, EventArgs args)
   at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
   at Telerik.Web.UI.RadFilterExpressionItem.OnBubbleEvent(Object source, EventArgs args)
   at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
   at System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
   at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.HandleError(Exception e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at ASP.site_home_aspx.ProcessRequest(HttpContext context) in c:\Users\David\AppData\Local\Temp\Temporary ASP.NET Files\root\b61e1bf9\22b85fdb\App_Web_se4njkoz.1.cs:line 0
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
               

We have tech support with you so we can open a ticket, but I think showing the problem in public may help others with a similar issue.

FYI: Whereas in my earlier message that I had stopped the page_init and page_load events calling every user control when they didn't need to... I have re-enabled that to eliminate that from the issue (i.e. all user controls will have their init and load when any control posts back, even though everything is ajax).

If you need any further info, please ask and I will try and provide what I can.

Thank you.
0
David
Top achievements
Rank 1
answered on 07 Mar 2013, 04:14 PM
If it is of any help, I have attempted to rip the code out into it's own little page, though I cannot reproduce the errors above as it is set up very differently (i.e. there are many layers to get the data and it would take me a week or so to even get close to reproducing the current situation I have).

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="test" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <div>
 
    <telerik:RadAjaxLoadingPanel Skin="Custom" EnableEmbeddedSkins="false" runat="server" ID="RadAjaxLoadingPanel1" />
    <div id="documentWindowRestrictionZone">
    <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1">
 
     <telerik:RadSplitter ID="rsDocumentsView" runat="server" Width="99%" Height="300">
    <telerik:RadPane ID="rpDocumentView" runat="server" Width="80%">
                <div class="documentTabContainer">
                    <div class="tabStripContainer">
                        <telerik:RadTabStrip runat="server" ID="rtsTabs" Orientation="HorizontalTop"
                            SelectedIndex="0" MultiPageID="rmpTabContent">
                            <Tabs>
                                <telerik:RadTab Text="Browse documents">
                                </telerik:RadTab>
                                <telerik:RadTab Text="Search">
                                </telerik:RadTab>
                            </Tabs>
                        </telerik:RadTabStrip>
                    </div>
                <telerik:RadToolTip runat="server" ID="rttDocumentGrid" TargetControlID="grdDocumentList">
                    Double-click a file to download it
                </telerik:RadToolTip>
                <telerik:RadMultiPage runat="server" ID="rmpTabContent" SelectedIndex="0">
                    <telerik:RadPageView runat="server" ID="rpvBrowse">
                        <telerik:RadGrid ID="grdDocumentList" runat="server" AllowSorting="False" EnableLinqExpressions="false" ClientSettings-AllowColumnsReorder="true" AutoGenerateColumns="False" CellSpacing="0" GridLines="None" Width="99%">
                        <MasterTableView TableLayout="Auto" ShowHeadersWhenNoRecords="true" NoDetailRecordsText="No documents found." EnableNoRecordsTemplate="true">
                            <NoRecordsTemplate><div class="GridNoItems">No documents found.</div></NoRecordsTemplate>                                             
                            <Columns>
                                <telerik:GridTemplateColumn Visible="false" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" DataField="MimeType" HeaderStyle-HorizontalAlign="Left" HeaderText="File type" ItemStyle-VerticalAlign="Top" ShowFilterIcon="false" SortExpression="MimeType" UniqueName="MimeType">
                                    <ItemTemplate>
                                        <asp:Label ID="lblFileType" runat="server" Text='<%# Eval("MimeType") %>' />
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn Visible="false" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" DataField="Name" HeaderStyle-HorizontalAlign="Left" HeaderText="File Name" ItemStyle-VerticalAlign="Top" ShowFilterIcon="false" SortExpression="FileName" UniqueName="FileName">
                                    <ItemTemplate>
                                        <asp:Panel ID="pnlFileIcon" runat="server" CssClass="fileIcon"></asp:Panel>
                                        <asp:Label ID="lblFileName" runat="server" Text='<%# Eval("Name") %>' /><asp:Image runat="server" ID="imgNew" ImageUrl="~/images/new_document.png" Visible="false" CssClass="newDocumentImage" />
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                             
                                <telerik:GridTemplateColumn Visible="false" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" DataField="CreatedOn" HeaderStyle-HorizontalAlign="Left" HeaderText="Created date" ItemStyle-VerticalAlign="Top" ShowFilterIcon="false" SortExpression="CreatedOn" UniqueName="CreatedOn">
                                    <ItemTemplate>
                                        <asp:Label ID="lblCreatedOn" runat="server" Text='<%# Eval("CreatedOn") %>'></asp:Label>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
 
                                <telerik:GridTemplateColumn Visible="false" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" DataField="ModifiedOn" HeaderStyle-HorizontalAlign="Left" HeaderText="Modified date" ItemStyle-VerticalAlign="Top" ShowFilterIcon="false" SortExpression="ModifiedOn" UniqueName="ModifiedOn">
                                    <ItemTemplate>
                                        <asp:Label ID="lblModifiedOn" runat="server" Text='<%# Eval("ModifiedOn") %>'></asp:Label>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
 
                                <telerik:GridTemplateColumn Visible="false" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" DataField="DocumentTypeDescription" HeaderStyle-HorizontalAlign="Left" HeaderText="Document type" ItemStyle-VerticalAlign="Top" ShowFilterIcon="false" SortExpression="DocumentTypeDescription" UniqueName="DocumentTypeDescription">
                                    <ItemTemplate>
                                        <asp:Label ID="lblDocumentTypeDescription" runat="server" Text='<%# Eval("DocumentType.Description") %>'></asp:Label>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
 
                                <telerik:GridTemplateColumn Visible="true" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" DataField="UniqueID" HeaderStyle-HorizontalAlign="Left" HeaderText="Unique Id" ItemStyle-VerticalAlign="Top" ShowFilterIcon="false" SortExpression="UniqueID" UniqueName="UniqueID" Display="false">
                                    <ItemTemplate>
                                        <%# Eval("UniqueID") %>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
 
                                <telerik:GridTemplateColumn Visible="true" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" DataField="DocumentRecordId" HeaderStyle-HorizontalAlign="Left" HeaderText="" ItemStyle-VerticalAlign="Top" ShowFilterIcon="false" UniqueName="DocumentRecordId" Display="false">
                                    <ItemTemplate>
                                        <%# Eval("DocumentRecordID") %>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
 
                            </Columns>                       
                        </MasterTableView>
                    </telerik:RadGrid>               
                    </telerik:RadPageView>
                    <telerik:RadPageView runat="server" ID="rpvSearch">
                        <telerik:RadAjaxLoadingPanel runat="server" ID="ralpSearch" Skin="Custom" EnableEmbeddedSkins="false" />
                        <telerik:RadAjaxPanel runat="server" id="rapSearch" LoadingPanelID="ralpSearch">
                            <div class="documentSearchContainer">
                                <telerik:RadFilter ID="uxRadFilter" runat="server" onapplyexpressions="uxRadFilter_ApplyExpressions" ExpressionPreviewPosition="None">
                                 
                                </telerik:RadFilter>
                            </div>
                            <telerik:RadGrid ID="grdSearchResults" runat="server" AllowSorting="True" EnableLinqExpressions="false" ClientSettings-AllowColumnsReorder="true" AutoGenerateColumns="False" CellSpacing="0" GridLines="None" Width="99%">
                                <MasterTableView TableLayout="Auto" ShowHeadersWhenNoRecords="true" NoDetailRecordsText="No documents found." EnableNoRecordsTemplate="true">
                                    <NoRecordsTemplate><div class="GridNoItems">No documents found.</div></NoRecordsTemplate>                                             
                                    <Columns>
                                        <telerik:GridTemplateColumn Visible="false" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" DataField="MimeType" HeaderStyle-HorizontalAlign="Left" HeaderText="File type" ItemStyle-VerticalAlign="Top" ShowFilterIcon="false" SortExpression="MimeType" UniqueName="MimeType">
                                            <ItemTemplate>
                                                <asp:Label ID="lblFileType" runat="server" Text='<%# Eval("MimeType") %>' />
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
                                        <telerik:GridTemplateColumn Visible="false" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" DataField="Name" HeaderStyle-HorizontalAlign="Left" HeaderText="File Name" ItemStyle-VerticalAlign="Top" ShowFilterIcon="false" SortExpression="FileName" UniqueName="FileName">
                                            <ItemTemplate>
                                                <asp:Panel ID="pnlFileIcon" runat="server" CssClass="fileIcon"></asp:Panel>
                                                <asp:Label ID="lblFileName" runat="server" Text='<%# Eval("Name") %>' /><asp:Image runat="server" ID="imgNew" ImageUrl="~/images/new_document.png" Visible="false" CssClass="newDocumentImage" />
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
                             
                                        <telerik:GridTemplateColumn Visible="false" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" DataField="CreatedOn" HeaderStyle-HorizontalAlign="Left" HeaderText="Created date" ItemStyle-VerticalAlign="Top" ShowFilterIcon="false" SortExpression="CreatedOn" UniqueName="CreatedOn">
                                            <ItemTemplate>
                                                <asp:Label ID="lblCreatedOn" runat="server" Text='<%# Eval("CreatedOn") %>'></asp:Label>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
 
                                        <telerik:GridTemplateColumn Visible="false" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" DataField="ModifiedOn" HeaderStyle-HorizontalAlign="Left" HeaderText="Modified date" ItemStyle-VerticalAlign="Top" ShowFilterIcon="false" SortExpression="ModifiedOn" UniqueName="ModifiedOn">
                                            <ItemTemplate>
                                                <asp:Label ID="lblModifiedOn" runat="server" Text='<%# Eval("ModifiedOn") %>'></asp:Label>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
 
                                        <telerik:GridTemplateColumn Visible="false" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" DataField="DocumentTypeDescription" HeaderStyle-HorizontalAlign="Left" HeaderText="Document type" ItemStyle-VerticalAlign="Top" ShowFilterIcon="false" SortExpression="DocumentTypeDescription" UniqueName="DocumentTypeDescription">
                                            <ItemTemplate>
                                                <asp:Label ID="lblDocumentTypeDescription" runat="server" Text='<%# Eval("DocumentType.Description") %>'></asp:Label>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
 
                                        <telerik:GridTemplateColumn Visible="true" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" DataField="UniqueID" HeaderStyle-HorizontalAlign="Left" HeaderText="Unique Id" ItemStyle-VerticalAlign="Top" ShowFilterIcon="false" SortExpression="UniqueID" UniqueName="UniqueID" Display="false">
                                            <ItemTemplate>
                                                <%# Eval("UniqueID") %>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
 
                                        <telerik:GridTemplateColumn Visible="true" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" DataField="DocumentRecordId" HeaderStyle-HorizontalAlign="Left" HeaderText="" ItemStyle-VerticalAlign="Top" ShowFilterIcon="false" UniqueName="DocumentRecordId" Display="false">
                                            <ItemTemplate>
                                                <%# Eval("DocumentRecordID") %>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
 
                                    </Columns>                       
                                </MasterTableView>
                            </telerik:RadGrid>
                        </telerik:RadAjaxPanel>        
                    </telerik:RadPageView>
                </telerik:RadMultiPage>
                                </div>
            </telerik:RadPane>
            </telerik:RadSplitter>
 </telerik:RadAjaxPanel>
    </div>
 
    </div>
    </form>
</body>
</html>

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;
 
namespace Portal
{
    public partial class test : System.Web.UI.Page
    {
        protected void Page_Init(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (uxRadFilter.FieldEditors.Count == 0)
                {
                    RenderGridFilters();
                }
            }
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        protected void uxRadFilter_ApplyExpressions(object sender, RadFilterApplyExpressionsEventArgs e)
        {
            RadFilterDynamicLinqQueryProvider provider = new RadFilterDynamicLinqQueryProvider();
            provider.ProcessGroup(e.ExpressionRoot);
            string expression = provider.Result;
        }
 
        private void RenderGridFilters()
        {
            List<RadFilterDataFieldEditor> defaultFilterField = new List<RadFilterDataFieldEditor>();
 
            defaultFilterField.Add(new RadFilterTextFieldEditor
            {
                DisplayName = "Name",
                FieldName = "Name",
                DataType = typeof(System.String)
            });
 
            defaultFilterField.Add(new RadFilterTextFieldEditor
            {
                DisplayName = "Description",
                FieldName = "Description",
                DataType = typeof(System.String)
            });
 
            defaultFilterField.Add(new RadFilterDateFieldEditor
            {
                DisplayName = "CreatedOn",
                FieldName = "CreatedOn",
                DataType = typeof(System.DateTime)
            });
 
            defaultFilterField.Add(new RadFilterTextFieldEditor
            {
                DisplayName = "DocumentTypeDescription",
                FieldName = "DocumentTypeDescription",
                DataType = typeof(System.String)
            });
 
 
            foreach (RadFilterDataFieldEditor dfe in defaultFilterField)
            {
                uxRadFilter.FieldEditors.Add(dfe);
            }
 
            if (uxRadFilter.RootGroup.Expressions.Count == 0)
            {
                uxRadFilter.RootGroup.AddExpression(new RadFilterContainsFilterExpression("Name") { Value = "" });
            }
        }
 
    }
}


We need to have a dynamic filter based on what columns we have set up earlier. The only way we can do this is to add the filter columns dynamically else there are viewstate issues. So, we are adding the columns dynamic like this.

Now, I am also trying to replicate the postback by not reloading the filter columns. (I have tested it with allowing the reload filter columns and without allowing them). Same issue either way.

Funny though that I am only getting the errors above with the new version of telerik. I am not immediately in a position to prove that the files listed above are failing with an older version of telerik.

Anyhow, the above, while not creating the same error is still creating an error... 'length' is null or not an object.

Just thought I would throw this into the mix.
0
David
Top achievements
Rank 1
answered on 07 Mar 2013, 04:58 PM
Hhhmmm... I seem to be adding to my own posts here...

My last post suggested the error was not related. However, the previous 2 errors were run with an error handling page set up in web.config.

I have now ran the last message with the error handler turned on and I get the exact same error as the previous two errors, depending on the scenario. The scenario being...

(Both scenarios, click the add Expression icon)

Allow the post back to occur (imagine no !IsPostBack)
the error I get is Parameter cannot be null or empty. Parameter name: fieldName.

Don't allow the postback 
the error I get is Object reference not set to an instance of an object.

Both errors are exactly what I get in the first two messages.

All help appreciated.
Thank you.
0
Antonio Stoilkov
Telerik team
answered on 11 Mar 2013, 11:37 AM
Hi David,

You could resolve your issue by following the help article below. The idea is to create the field editors either in Page_Load event with a IsPostBack condition or create them every time on Page_Init. Your current issue is caused from the creation of the controls in Page_Init and then skipping to recreate them on the next page postback with the IsPostBack condition.

All the best,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
David
Top achievements
Rank 1
answered on 11 Mar 2013, 03:01 PM
Hi,

So, even though I am not actually touching the user control (which is hosted in an AJAX container by itself), I still have to run the page_init?

hhmmm... I thought the whole purpose of AJAX was to only work on parts of a page at a time and not affect other parts.

It is unfortunate that the part the code works with, that particular 'widget' is a pretty time consuming one.
0
Antonio Stoilkov
Telerik team
answered on 12 Mar 2013, 09:17 AM
Hi David,

The experienced behavior is expected. I have examined the code provided in the forum thread and theRadFilter and all other controls are positioned in one RadAjaxPanel which causes every control to be recreated on every ajax request. The recreation of the RadFilter could be achieved by creating theRadFilter every time in the Page_Init event or once in Page_Load which will persist in the RadFilterViewState and there will be no need to recreate it manually.

Additionally, I have created a sample page showing both approaches. Note that I have not experienced any errors with the latest official release.
  • Page_Init creation - the expressions should be added only once. However, the FieldEditors should be added on every Page_Init
protected void Page_Init(object sender, EventArgs e)
{
    RenderGridFilters();
  
    if (!IsPostBack)
    {
        if (uxRadFilter.RootGroup.Expressions.Count == 0)
        {
            uxRadFilter.RootGroup.AddExpression(new RadFilterContainsFilterExpression("Name") { Value = "" });
        }
    }
}
  • Page_Load creation
protected void Page_Load(object sender, EventArgs e)
{
    // The second option to create the RadFilter. Note that the editor should be first added
    // to the FieldEditors collection and then the assing the properties because otherwise
    // the properties would not be persisted in ViewState
  
    if (!IsPostBack)
    {
        RadFilterDataFieldEditor editor = new RadFilterTextFieldEditor();
        uxRadFilter.FieldEditors.Add(editor);
        editor.DisplayName = "Name";
        editor.FieldName = "Name";
        editor.DataType = typeof(System.String);
  
        if (uxRadFilter.RootGroup.Expressions.Count == 0)
        {
            uxRadFilter.RootGroup.AddExpression(new RadFilterContainsFilterExpression("Name") { Value = "" });
        }
    }
}

Kind regards,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
David
Top achievements
Rank 1
answered on 12 Mar 2013, 04:25 PM
Hi telerik,

Still having issues.

The code 'appears' to be working with the previous version of telerik but not the current version.

I have modified my sample code to have...

protected void Page_Init(object sender, EventArgs e)
        {
            //if (!IsPostBack)
            //{
                if (uxRadFilter.FieldEditors.Count == 0)
                {
                    RenderGridFilters();
                }
            //}
 
                if (!IsPostBack)
                {
                    if (uxRadFilter.RootGroup.Expressions.Count == 0)
                    {
                        uxRadFilter.RootGroup.AddExpression(new RadFilterContainsFilterExpression("Name") { Value = "" });
                    }
                }
        }

but am still experiencing problems. The working version is on a live server and in its real code base, the example above is just a snapshot so that I can test there is a problem and cannot put this page on the live server.

(I have removed the AddExpression from the RenderGridFilters, from the live code, I only copied it there as it was actually in a different method though I knew I needed it.)

The error I am experiencing is a JS error popping up...

Line: 9
Error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 0

and in the developer tools of IE 10 (Script console)

SCRIPT7002: XMLHttpRequest: Network Error 0x2f8f, Could not complete the operation due to error 00002f8f.
Home

SCRIPT5022: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 0
Telerik.Web.UI.WebResource.axd, line 9 character 15443



This is happening when I attempt to click the AddExpression button (the green + )

FWIW, I am using IE10 and .NET 4.0. I have applied the hotfix that causes some issues with the MicrosoftAjax stuff.

Thank you.
0
Antonio Stoilkov
Telerik team
answered on 15 Mar 2013, 08:52 AM
Hi David,

Based on your description it is hard to determine the cause of the issue. However, you could try the recreation of the RadFilter control in the Page_Load event. If your issue still persists we will need a sample project showing the unwanted behavior so we could debug it on our side. You could upload the project on a external sharing service and provide us with an URL.

Greetings,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
David
Top achievements
Rank 1
answered on 18 Mar 2013, 09:30 AM
Hi Antonio,

I have uploaded a test page to my webspace. It can be downloaded from http://www.revilloc.com/test.zip

Inside the cs file is a bool, usePageInit.

This project will work in both IE 10 and Chrome when the bool usePageInit is set to false. However, with usePageInit set to true, it will fail in both Chrome and IE 10.

The code works with the previous version of telerik that we had... we are using page_init though as we couldn't get it to work in page_load, though as yet, I don't know what would not work as it was not my project. :-(

I look forward to having this working again.

David.
0
Antonio Stoilkov
Telerik team
answered on 21 Mar 2013, 06:45 AM
Hello David,

I have further investigate the project and you are correct. There is an issue with RadFilter creation in Page_Init. I have notified our developers so they could immediately take a look at the bug. Note that currently you could create the RadFilter only in Page_Load. Additionally, I have updated your Telerik points for your bug report.

Greetings,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Paulo
Top achievements
Rank 1
answered on 28 Oct 2013, 02:54 PM

Hello Antonio,

Are there any updates about this issue?

We have a very similar context and we’re getting the same kind of errors around viewstate and radfilter recreating.

There is only a “Main” RadGrid with columns created on runtime (on page_init) based on fields selected in a “Fields” RadGrid inside a tooltip. Everything ok until now. Then there’s this radfilter with FilterContainerID=<MainGrid> that gives errors on postback.

We’re using Telerik AJAX 2013.2.717.40.

 

Thank you for any help

0
Antonio Stoilkov
Telerik team
answered on 31 Oct 2013, 06:48 AM
Hello Paulo,

The issue with creating RadFilter in Page_Init have been already resolved. You could take a look at both articles below which describe how to create RadGrid and RadFilter editors in code behind in order to observe if you are doing anything wrong. Note that the order for setting the columns and editor properties and adding them to their respective collections does matter.

If your issue still persists you could assemble a sample project showing the unwanted behavior so we could debug it and advice you with the best possible solution. You could either open a formal support ticket attaching the project or upload it in a public sharing site and give us the URL.


Regards,
Antonio Stoilkov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Filter
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Antonio Stoilkov
Telerik team
Paulo
Top achievements
Rank 1
Share this question
or