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

Manager/Panel file download

1 Answer 50 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Reuven
Top achievements
Rank 1
Reuven asked on 27 Sep 2010, 12:06 AM

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)

 

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 27 Sep 2010, 12:07 PM
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
Tags
Ajax
Asked by
Reuven
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or