ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Downloading document from grid button
Title:
B
I
{code}
?
I'm trying to call a server FileResult action from a button in my grid. But I'm having trouble figuring out how to not have it use a popup. I can't send an Id value to retrieve this file, it's a combination of FileName and CustomerName in the grid model and ViewBag. I'm able to get the correct data back to the server, and the method sends back a File, but I'm not sure how to properly create the button as the only way I can get it to work is by using InitPopup, and so the byte data from the file tries to display itself in a popup view. Here's the popup: @Html.Awe().InitPopup().Name("downloadFile").Url(Url.Action("DownloadDocument", "AccessorialCRUD")) and the button: var downloadBtnFormat = Html.Awe().Button() .Text("Download") .CssClass("o-pad") .OnClick(Html.Awe().OpenPopup("downloadFile") .Params(new { fileName = ".(Name)", customerName = Model.CustomerName })) .ToString(); and the column: new Column { ClientFormat = downloadBtnFormat, Header = "File", Width = 90 } What should I do in order to be able to pass the file Name and CustomerName back to the controller but have the browser download the file instead of trying to display the data in a popup?
Save Changes
Cancel
Sean Davidson
asked at 16 May 2022
have a look at the `getFile` js function in the view code here: https://demo.aspnetawesome.com/GridExportToExcelDemo
at 16 May 2022
Omu
How could that be used to pull in data from a grid row to be passed to the controller?
at 17 May 2022
Sean Davidson
like in most of our demos where there's a button in a grid row, for example here: https://demo.aspnetawesome.com/GridDemo/CustomFormat you can see `ClientFormatFunc = "condButton"`, and `condButton` js function has `onclick="awe.open...` you could have `onclick="getFile...` instead
at 17 May 2022
Omu
Answers
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK