I have the following javascript code and controller action in my asp.net-mvc project:
JavaScript:
$("#exportPPT").live('click', function (e) { window.location.href = "/Initiative/GenerateFile" + GenerateParams(); });
C # controller:
public ActionResult GenerateFile(MyParams myParams) { var template = Server.MapPath(PPT_ROOT + "/template.pptx"); IEnumerable<Order> orders = Model.GetOrders(myparams); var pptResults = GeneratePowerpointFile(orders); return File(pptResults.Content, "application/vnd.ms-powerpoint", pptResults.FileName); }
but under certain conditions, say when orders.Count () is 0, instead of generating a file, I would prefer to return an error message to the user, indicating that you have an error.
What is the best way to achieve this, given the code above? I was thinking of changing it to an ajax call, but I was not sure how to load my Fie () and the package that is in the json request (or if this is supported).
Any suggestions?
jquery asp.net-mvc powerpoint
leora
source share