ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
PopupForm - return a file after closing popup on Ok
Title:
B
I
{code}
?
I have a button that call a popupform like your sample https://demo.aspnetawesome.com/PopupFormDemo#Sending-client-side-parameters-to-server-on-content-load after user presses the OK button in your sample return a as json I need to close the popupform and return a FileResult object I try like this .. [HttpPost] public virtual FileResult MakeDocument(DocModel model) { byte[] fileBytes = System.IO.File.ReadAllBytes(@"c:\temp\test.txt"); string fileName = "myfile.ext"; return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName); } but seem not run very well
Save Changes
Cancel
mtugnoli
asked at 05 Mar 2019
Answers
B
I
{code}
?
`PopupForm` post action should return a `Json(obj1)` object which will close the popup and execute the `success function(obj1)` or view/content/string which will replace the popup content. You can return a `Json(info)` and in the success function use the `info` to make a separate request that will return the file. You can copy the `getFile` js function from here: https://demo.aspnetawesome.com/GridExportToExcelDemo and call it in the success function of your `PopupForm`
Save Changes
Cancel
Omu
answered at 05 Mar 2019
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