asp.net-mvc-2

Use Json and AjaxLink to Toggle Link Values in ASP.NET MVC 2

旧城冷巷雨未停 提交于 2019-12-12 10:21:33
问题 I have a list of Child objects. I would like to be able to toggle whether they are included in a smaller list of objects which have a relationship to a Parent object. Like so: <% foreach(var child in Model.AllPossibleChildren)%> <% { %> <tr> <td> <%if(child.Link.Any(r => r.Id == Model.Parent.Id)) { %> <%:Ajax.ActionLink("Remove", "RemoveChild", new { aId = Model.Parent.Id, rId = child.Id }, null)%> <% } else { %> <%:Ajax.ActionLink("Add", "AddChild", new { aId = Model.Parent.Id, rId = child

asp.net mvc3 RouteLink

六眼飞鱼酱① 提交于 2019-12-12 10:16:09
问题 I have just upgraded my mvc2 app to mvc3. And the routelink stopped working. any clue?? Global routes.MapRoute( "Category", "category/{cat}/{subcat}/{page}/{viewall}", new { controller = "Category", action = "Index", cat = UrlParameter.Optional, subcat = UrlParameter.Optional, page = UrlParameter.Optional, viewall = UrlParameter.Optional } ); View <%: Html.RouteLink("Women's", "Category", new { cat = "Women", subcat = "" })%> This is how it renders <a href="">Women's</a> 回答1: It's a

CultureInfo issue with Modelbinding double in asp.net-mvc(2)

自作多情 提交于 2019-12-12 08:08:09
问题 In my Jquery script I post two doubles using the browser's CultureInfo (en-UK) that uses the . as a fraction separator. My MVC app is running on a server with locale nl-BE using the , as a fraction separator. [AcceptVerbs(HttpVerbs.Post)] public JsonResult GetGridCell(double longitude, double latitude) { var cell = new GridCellViewModel { X = (int)Math.Round(longitude, 0), Y = (int)Math.Round(latitude, 0) }; return Json(cell); } The modelbinding fails because of the parsing issue. I think it

How to overcome this security issue

↘锁芯ラ 提交于 2019-12-12 07:13:01
问题 I have implemented an ajax-polling script that calls an action in the server Controller every 10 seconds. With the response, I replace the content of a div : function getFoo() { var link = '/Secure/GetFoo'; $.post(link, function (response) { $('#FooSection').replaceWith(response); }); setTimeout("getFoo();", 10000); } This is done through https . After some time of being "idle", IE displays the following message: This page is accessing information that is not under its control. This poses a

Change label on change DropDownListFor value

十年热恋 提交于 2019-12-12 06:36:30
问题 I use a DropDownListFor and a label text on my page. <%=Html.DropDownListFor(x => x.MotiveClientType, new SelectList( Model.ClientMotives, "Id", "Label", Model.MotiveClientType), new { id = "ddlMotiveClientType" } )%> How can I change my label when selecting value on my DropDownListFor ? 回答1: I'm not aware of any functionality native to ASP.NET MVC that will allow you to do this, but doing it with jQuery is a fairly trivial matter. Here's an example of hooking up an event handler to the

In my ASP.NET MVC app how can I determine if any property in my domain Model has changed?

吃可爱长大的小学妹 提交于 2019-12-12 06:33:36
问题 I am working on the MVC prototype of a very large and complex ASP.NET 2.0 Webforms based business product suite for an organization. One of the capabilities inbuilt into the existing app is that it only hits the database to store a result set if the user made any changes at all on the Webforms UI. The web app has a complete layer built in to track this "if changed by user" thing. I was wondering if within ASP.NET MVC there is a provision/functionality to determine what property was changed by

generate dynamic pie chart and page redirection in mvc2

感情迁移 提交于 2019-12-12 06:32:37
问题 I want to know how to generate a pie chart dynamically. and how to redirect a page to another web page? 回答1: You could use Silverlight for the pie chart, it is very good for those and dynamic. for redirecting the page, if the page you want to redirect to is a View which is rendered by an action method, you can redirect to that action and it will redirect the page to its corresponding view after doing its magic: public ActionResult SomeAction(int id) { // Do your things here return

asp.net mvc2 task scheduler

醉酒当歌 提交于 2019-12-12 06:09:28
问题 I have an asp.net mvc 2 app, and I need to run a task (call WS, save into db) once a day. What is the suggested way for this? One thing, I have a feeling I would like to execute this task from within the webapp. Does anyone have any suggestions: I was considering .net quartz or regular System.Timers.Timer? Does anyone see any problems? Any other better solutions? Thanks a lot --MB 回答1: Why do you want to run this from the webapp? You have no way of even knowing if the webapp will be running

Is it possible to restrict windows authenticated users in an ASPNet app to specific domains?

三世轮回 提交于 2019-12-12 05:39:12
问题 I'm in the process of pulling a classic ASP app into Mvc2. I'll be deploying to an intranet and have been asked to enable support for Windows Authentication. The network I'll be deploying to has a few AD Domains and I'll only need to integrate with one in particular. Is it possible to use Windows Authentication and only allow authentication within a particular domain? Along those same lines, it's not uncommon for a user to have an account in multiple domains (the account names themselves are

Binding form values to a complex type

丶灬走出姿态 提交于 2019-12-12 05:38:14
问题 I've used the MVC pattern for a while now and have been getting on fine, however I've got totally stuck. I have a view which shows a collection of complex objects, with a partial view as follows: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ThreeSixtyScheduling.Areas.Products.Models.PartsOnOrderModel+PartOnOrder>" %> <tr> <% using (Html.BeginForm("UpdateStockDueDate", "PartsOnOrder", FormMethod.Post)) { %> <td><input type="hidden" name="CallAppointmentDate" value="<%=