Manager/Panel file download

2 posts, 0 answers
  1. Reuven
    Reuven avatar
    19 posts
    Member since:
    Jun 2009

    Posted 26 Sep 2010 Link to this post

    Am pulling my hair out on this...

    By scenario is kind of complex, but I have a masterpage with a radajaxmanager, then a page with multiple use controls. In one of the controls, I have a button within a radgrid that I want to generate a download request:

    Response.Clear()
    Response.ContentType = "Application/msword"
    Response.AddHeader("content-disposition", "attachment;filename=test.xml")
    Response.Write(teststring)
    Response.End()

    Obviously, I need to disable AJAX for this postback...
    In my grid, I have a GridTemplateColumm that has a btnGenerate
    On the grid's ItemDataBound:
    Dim sm As ScriptManager = ScriptManager.GetCurrent(Page)
    sm.RegisterPostBackControl(CType(e.Item.FindControl("btnGenerate"), LinkButton))

    But no matter what I try, when the Grid's ItemCommand is raised by the button, it remains an AJAX request.

    Thanks,
    Reuven
    (I don't want to save the generated file nor run it through a handler to generate since it contains confidential data)

     

  2. Daniel
    Admin
    Daniel avatar
    4949 posts

    Posted 27 Sep 2010 Link to this post

    Hello Reuven,

    You can cancel the AJAX request in the OnRequestStart client-side event. Here is how:

    1. Attach the handler to RadAjaxManager
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <ClientEvents OnRequestStart="requestStart" />

    2. Put the JS code in the MasterPage
    ...
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <script type="text/javascript">
        function requestStart(sender, args)
        {
            if (args.get_eventTarget().indexOf("MY_BUTTON_ID") >= 0)
                args.set_enableAjax(false);
        }
    </script>
    ...

    Best regards,
    Daniel
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
Back to Top