GridAttachmentColumn: ConditionalPostback & "Object Required" Errors

5 posts, 0 answers
  1. Richard Weeks
    Richard Weeks avatar
    95 posts
    Member since:
    Oct 2009

    Posted 12 Oct 2011 Link to this post

    I am encountering strange issues in my continuing quest to get GridAttachmentColumn to play nice with AJAX.

    I have implemented conditional postback as follows:

    Code behind

    if (this.Master != null)
    {
        var ajaxManager = (RadAjaxManager)this.Master.FindControl("TelerikAjaxManager");
      
        if (ajaxManager != null)
        {
            ajaxManager.ClientEvents.OnRequestStart += "ConditionalPostback";
        }
    }

    Script in the content page

    function ConditionalPostback(sender, eventArgs)
    {
        var eventTarget = eventArgs.get_eventTarget();
      
        if (eventTarget == "<%=this.AttachmentsGrid.UniqueID %>")
        {
            var eventArgument = eventArgs.get_eventArgument();
      
            if (eventArgument.indexOf("Update") > -1 || 
                eventArgument.indexOf("PerformInsert") > -1)
            {
                eventArgs.set_enableAjax(false);
            }
        }
    }

    function GridOnCommand(sender, args)
    {
        if (args.get_commandName() == "DownloadAttachment")
        {
            var manager = $find('<%= RadAjaxManager.GetCurrent(Page).ClientID %>');
      
            manager.set_enableAJAX(false);
      
            setTimeout(function () { manager.set_enableAJAX(true); }, 0);
        }
    }

    Snippet of the RadGrid

    <telerik:RadGrid 
        AutoGenerateColumns="False" 
        AutoGenerateEditColumn="True" 
        DataSourceID="AttachmentsDataSource" 
        ID="AttachmentsGrid" 
        runat="server">
        <MasterTableView 
            DataKeyNames="Id" 
            DataSourceID="AttachmentsDataSource">
            <Columns>
                <telerik:GridAttachmentColumn 
                    DataSourceID="AttachmentDataSource"
                    MaxFileSize="1048576" 
                    EditFormHeaderTextFormat="Upload Attachment:"
                    HeaderText="Attachment"
                    HeaderTooltip="Download Activity Attachment"
                    AttachmentDataField="Attachment" 
                    AttachmentKeyFields="Id"
                    FileNameTextField="FileName" 
                    DataTextField="FileName"
                    UniqueName="Attachment">
                </telerik:GridAttachmentColumn>
            </Columns>
        </MasterTableView>
        <ClientSettings>
            <ClientEvents OnCommand="GridOnCommand" />
        </ClientSettings>
    </telerik:RadGrid>

    The grid is contained within a TabStrip with associated pageviews.

    I can upload an attachment, delete etc. but when I click a link in the tab strip, i receive two errors:

    b.toUpperCase is not a function
      
    Function.__typeName="Function";Functio...terClass("Sys.Net.WebServiceError");
      
    Teleri...8366029 (line 6)
      
    h is not a constructor
      
    Function.__typeName="Function";Functio...terClass("Sys.Net.WebServiceError");
      
    Teleri...8366029 (line 6)

    Message: Object doesn't support this property or method
    Line: 6
    Char: 18774
    Code: 0
    URI: http://localhost:63311/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=TelerikScriptManager_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3ae71d0a15-7471-4384-9905-78bdf2047cba%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%2c+Version%3d2011.2.712.40%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aen-US%3af9722142-3e1c-4803-86df-ecfc0d24f144%3a16e4e7cd%3aed16cbdc%3a874f8ea2%3af7645509%3a24ee1bba%3af46195d3%3a19620875%3a490a9d4e%3abd8f85e4%3a86526ba7%3ae330518b%3a1e771326%3ac8618e41%3ac172ae1e%3a9cdfc6e7%3ae4f8f289%3a8e6f0d33%3a6a6d718d%3a58366029

    Message: Object expected
    Line: 6
    Char: 54851
    Code: 0
    URI: http://localhost:63311/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=TelerikScriptManager_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3ae71d0a15-7471-4384-9905-78bdf2047cba%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%2c+Version%3d2011.2.712.40%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aen-US%3af9722142-3e1c-4803-86df-ecfc0d24f144%3a16e4e7cd%3aed16cbdc%3a874f8ea2%3af7645509%3a24ee1bba%3af46195d3%3a19620875%3a490a9d4e%3abd8f85e4%3a86526ba7%3ae330518b%3a1e771326%3ac8618e41%3ac172ae1e%3a9cdfc6e7%3ae4f8f289%3a8e6f0d33%3a6a6d718d%3a58366029


    I copied from Firebug / IE.

    After ok'ing the alerts, the page loads but with all the telerik styling and functionality in the page broken.

    Any ideas what is going on?

    Richard

    Update (14/10/2011): The issue is caused when there is a RadComboBox within the PageView of the TabStrip.If the ConditionalPostback does not fire the first time, I'm fine but if it does, this error happens. This seems strange to me because afterwards, AJAX is back on and ConditionalPostback doesn't actually do anything when navigating through the TabStrip PageViews.

    Even if I just put in a simple

    <

     

     

    telerik:RadComboBox runat="server" ID="test"></telerik:RadComboBox>

     

    I get the errors.

    I hate JavaScript.
  2. Richard Weeks
    Richard Weeks avatar
    95 posts
    Member since:
    Oct 2009

    Posted 13 Oct 2011 Link to this post

    I opened up a support ticket.

    Richard
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Rob
    Rob avatar
    43 posts
    Member since:
    Aug 2010

    Posted 01 Feb 2012 Link to this post

    Did the support ticket solve the problem?  I'm seeing similar errors on a page where a RadGrid is loaded through a RadAjaxManager.  It doesn't seem to be stopping things working, but it does cause annoying error popups in IE8.
  5. Richard Weeks
    Richard Weeks avatar
    95 posts
    Member since:
    Oct 2009

    Posted 01 Feb 2012 Link to this post

    I got something working though I really can't remember what trail I took to get there.

    Our pages are very complex so there can be many different factors at work.

    What I tend to do is take every element out of my pages, one by one, until I can isolate the exact cobtrol causing the problem, then go from there. Sorry I can't be helpful :(

    Watch out for scripts and page writes interfering. Wrap all such in RadCodeBlock, even (fyi only!):

    <telerik:RadCodeBlock runat="server" ID="AppSettingCodeBlock">
    <%: ConfigurationManager.AppSettings["AppName"] %>
    </telerik:RadCodeBlock>

    Also, things like form decorator can play merry hell with complex pages.

    Richard

  6. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 06 Feb 2012 Link to this post

    Hello Rob,

    Could you please elaborate a bit more eon the exact scenario you are implementing and the errors you are facing in IE8 browser. Providing your page markup and the related code  behind as well as the errors stack trace will help us isolate the root cause of the problem and provide more to the point answer.

    Regards,
    Maria Ilieva
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017