asp.net-mvc-5

Export html table into CSV file , always return empty file

那年仲夏 提交于 2019-12-02 04:19:53
I am working on an asp.net mvc5 web application. and i need to implement a functionality to export an Html table into a .csv file . so i added the following link :- <a href="#" class="export">Export Table data into Excel</a > and i have the following script:- $(document).ready(function () { function exportTableToCSV($table, filename) { var $rows = $table.find('tr:has(td)'), // Temporary delimiter characters unlikely to be typed by keyboard // This is to avoid accidentally splitting the actual contents tmpColDelim = String.fromCharCode(11), // vertical tab character tmpRowDelim = String

MVC Owin Cookie Authentication - Override ReturnUrl Generation

。_饼干妹妹 提交于 2019-12-02 04:09:24
问题 I have an MVC application using Owin Cookie Authentication. I have SlidingExpiration enabled and working. However, when a user's login expires and they are sent back to the LoginPath, the ReturnUrl is giving me some problems: I only want the ReturnUrl to be included if it points to a GET action, not a POST action. I would like to include the PathAndQuery instead of just Path so that I can re-fill any items the user might have had filled in on a form. I tried creating my own AuthorizeAttribute

MVC Context Menus Missing

瘦欲@ 提交于 2019-12-02 03:45:23
I've been following this tutorial http://www.asp.net/mvc/tutorials/mvc-5/introduction/getting-started on MVC 5. I've got as far as trying to add a controller, and when I right-click on controllers and choose "Add", I don't get some of the options in the picture - e.g. "Controller" or "New Scaffolded Item...". I'm using VS 2013 Professional, and have uninstalled and reinstalled, tried repairing the installation, all to no avail. Has anyone got any ideas? Thanks in advance 来源: https://stackoverflow.com/questions/21501218/mvc-context-menus-missing

Redirect to shared Error view from Global.asax on MVC unhandled exception

半腔热情 提交于 2019-12-02 03:16:21
问题 I've been reading about the different ways to perform error handling in ASP.MVC. I know about try/catch within a controller, and also about [HandleError] at controller-level. However, I am trying to perform global error handling for unhandled exceptions that could occur anywhere in the application (the wow - we never expected a user to do that! type of thing). The result of this is that an email is sent to dev's: This is working fine: protected void Application_Error() { Exception last_ex =

How To Convert Json to google visualization datatable

断了今生、忘了曾经 提交于 2019-12-02 03:15:51
问题 I have a method with ajax call to the server to get json result var jsonData = $.ajax({ url: '/Reports/GetJsonData', type: 'GET', dataType: 'json', error: function (err) { alert("Error : "+err.statusText); } }).responseText; Then I can get the Following Json result to the "jsonData" variable. [ {"LineName":"L1","Car":23,"Bus":0,"Motorcycle":0,"Person":0,"Others":0} ,{"LineName":"L2","Car":0,"Bus":0,"Motorcycle":6,"Person":0,"Others":0} ,{"LineName":"L3","Car":10,"Bus":20,"Motorcycle":36,

Failing to pass data from view to the Action by Html.BeginForm()

别等时光非礼了梦想. 提交于 2019-12-02 03:10:48
I am very new at asp.net mvc, so the reason behind my failure might be something basic as well, but I can't seem to find it after nearly a days work now. What I am trying to do is to get the edited Model from the Index view and pass it to a second action which does not have view and returns return RedirectToAction("Index") in the related controller. In OrdersItemsController my Action is as the following: [HttpPost] [ValidateAntiForgeryToken] public ActionResult MarkedShipped(IEnumerable<orders_items> orderItems) { if (ModelState.IsValid) { foreach (var item in orderItems) { unitOfWork

Customized DataAnnotationsModelMetadataProvider not working

随声附和 提交于 2019-12-02 02:07:26
I have many properties that require 1 or more validation attributes, like the following: public class TestModel { [Some] [StringLength(6)] [CustomRequired] // more attributes... public string Truck { get; set; } } Please note all the above annotations work. I do not want to write that all the time because whenever Some is applied, all other attributes are also applied to the property. I want to be able to do this: public class TestModel { [Some] public string Truck { get; set; } } Now this is doable by inheriting; therefore, I wrote a custom DataAnnotationsModelMetadataProvider and overrode

Pass entire object from view to controller in ASP.NET MVC 5

老子叫甜甜 提交于 2019-12-02 00:42:24
问题 Is there a way to pass entire object from ASP.NET MVC 5 View to a Controller? This is my situation: I have a View that displays all rows from a DB table The view's model is IEnumerable Each row has a link after it's data that leads to the scaffolded UPDATE view Is there a way to pass the entire object to the Update controller method so it would initially fill the form inputs with the old data? Something like: @Html.Action("Update me!", "Update", new { objectFromModelList }) And then in the

Redirect to shared Error view from Global.asax on MVC unhandled exception

做~自己de王妃 提交于 2019-12-02 00:31:59
I've been reading about the different ways to perform error handling in ASP.MVC. I know about try/catch within a controller, and also about [HandleError] at controller-level. However, I am trying to perform global error handling for unhandled exceptions that could occur anywhere in the application (the wow - we never expected a user to do that! type of thing). The result of this is that an email is sent to dev's: This is working fine: protected void Application_Error() { Exception last_ex = Server.GetLastError(); Server.ClearError(); // send email here... Response.Redirect("/Login/Login"); }

How can I refresh partial view and the main view at the same time?

南楼画角 提交于 2019-12-01 23:22:02
1) Here is the controller method of my main view: public ActionResult PredefPageLoad() { List<PredefineViewsView> predefViewsViews = null; try { using (PanSenseEntities context = new PanSenseEntities()) { int userID = Convert.ToInt32(Session["LoggedUserID"]); predefViewsViews = (from x in context.PredefineViewsViews where x.UserID == userID select x).ToList(); } } catch (Exception e) { Console.WriteLine(e); } return View(predefViewsViews); } 2) So my main view is displays a web grid which contains in each row an ID, a name and an amount of it's sub names , as well as image icons for add, edit