asp.net-mvc-3

MVC custom login authentication

断了今生、忘了曾经 提交于 2021-02-10 15:13:59
问题 Hi I'm developing an app in MVC and I have a problem with login, I want to know how can I manage the login depending on the user role. While the moment the login works fine but I need to identify the role user for sending to different pages I have a table in my database call Employee and one column is call IdPosition that is referred to another table call Position. Here is my code [HttpPost] public ActionResult Autorizacion(Pepitos.Models.Employee employee) { using (pepitosEntities db = new

How to call a server-side function from javascript in MVC?

泪湿孤枕 提交于 2021-02-10 05:45:53
问题 I am doing amendments in my MVC application in order to disallow users to open more than one tab/ window within a single session. I am taking reference of this article (click here) in order to do that. This article is written for asp.net whereas I need to implement this feature for ASP.NET MVC. I think all this should be possible in MVC, however, I am not sure what should I do to re-write this if(window.name != "<%=GetWindowName()%>") GetWindowName() is a function I have created in my

ASP.NET MVC 3 - pass data to a partial view in Layout

天大地大妈咪最大 提交于 2021-02-08 10:50:26
问题 I'm working on a ASP.NET MVC 3 application, but I'm rather new to MVC in general. I have a partial view in a my application layout view that needs to have data passed to it. this will appear on every page. Is there a way to make this happen so I don't have to load that data into the view model for every action in the entire site? As in, if a user navigates to Mysite/admin/settings, I would like to have the partial view on the layout be able to somehow receive the data that it needs without me

ASP.NET MVC 3 - pass data to a partial view in Layout

隐身守侯 提交于 2021-02-08 10:48:27
问题 I'm working on a ASP.NET MVC 3 application, but I'm rather new to MVC in general. I have a partial view in a my application layout view that needs to have data passed to it. this will appear on every page. Is there a way to make this happen so I don't have to load that data into the view model for every action in the entire site? As in, if a user navigates to Mysite/admin/settings, I would like to have the partial view on the layout be able to somehow receive the data that it needs without me

How to create new entity object, modify it in Model before SaveChanges()

巧了我就是萌 提交于 2021-02-08 03:28:11
问题 I've been dwelling with this issue for hours and couldn't figure out the problem. So I'm using ASP.NET MVC 3 with Entity Framework 4.1. I am writing the account management controller and models from scratch. My problem is that whenever the Controller receives the filled-up entity object from the View and sends it onwards to the Model, the Model won't save it if I try to modify any of the fields beforehand. Here is the relevant portion of my model, named ModelManager.cs : public class

How to create new entity object, modify it in Model before SaveChanges()

我只是一个虾纸丫 提交于 2021-02-08 03:27:08
问题 I've been dwelling with this issue for hours and couldn't figure out the problem. So I'm using ASP.NET MVC 3 with Entity Framework 4.1. I am writing the account management controller and models from scratch. My problem is that whenever the Controller receives the filled-up entity object from the View and sends it onwards to the Model, the Model won't save it if I try to modify any of the fields beforehand. Here is the relevant portion of my model, named ModelManager.cs : public class

How to send data through actionlink in asp.net?

瘦欲@ 提交于 2021-02-07 19:41:34
问题 In the application that I am trying to make, I have a menu in my view as below: <ul id="menu"> <li>@Html.ActionLink("Create Project", "Display", "CreateDisplay")</li> <li>@Html.ActionLink("Open", "About", "Home")</li> </ul> where CreateDisplay is the name of a controller and Display is a method in that controller which will call another view. But, I want the Display method to accept certain parameters like username of the person. In the current view, I have obtained the username as @ViewData[

jQuery.parseJSON not working for JsonResult from MVC controller action

ぃ、小莉子 提交于 2021-02-07 17:22:13
问题 I am trying to use jQuery.parseJSON to parse out the return value from an MVC3 controller action. Controller: [HttpPost] public JsonResult LogOn(LogOnModel model, string returnUrl) { .. do stuff .. if (errors.Count() < 0) { return Json(new object[] { true, model, errors }); } return Json(new object[] { false, model, errors }); } jQuery: $.ajax({ url: form.attr('action'), type: "POST", dataType: "json", data: form.serialize(), success: function (data) { var test = jQuery.parseJSON(data); } });

How to call MVC ChildActionOnly Controller Action using jQuery

三世轮回 提交于 2021-02-07 12:44:11
问题 I have a DropDownListFor that is in a Partial View. On change it fires a jQuery script, but Fiddler shows an HTTP 500 Error: The action 'LanguageListPartial' is accessible only by a child request. The calling script: <script type="text/javascript"> $(function () { $('#SelectedLanguage').on('change', function () { var culture = $(this).val(); $('#test').load("/Account/LanguageListPartial/" + culture, function () { location.reload(true); }); }); }); </script> I wouldn't want that Controller

Url.Action Passing string array from View to Controller in MVC#

坚强是说给别人听的谎言 提交于 2021-02-07 10:50:14
问题 I have a method that returns an array ( string[] ) and I'm trying to pass this array of strings into an Action.Currently I can't pass my parameters. I am new in MVC3. Pls let me know why I can't pass parameter to ActionResult..I already define ActionResult with Same parameter name.. thanks all in advance.... $('#export-button').click(function () { var columnLength = $("#grid")[0].p.colNames.length; var columnNames = ""; for (var i = 0; i < columnLength; i++) { if ($("#grid")[0].p.colModel[i]