asp.net-mvc-2

How to create pages with different permissions' views

你说的曾经没有我的故事 提交于 2019-12-07 02:44:31
I need some help to create pages with different views. Don't get me wrong, I don't want anyone to write code for me, I just want to know what I'll need to implement. I'll detail what I need: Ex: Facebook page. If I'm at my profile's page I have one type of view, I can edit all my data, see even not set data and add more information. If I'm visiting a friend's page I can only see what he wants me to and interact with his pages as far as he allowed me. Ex2: One user posted info on some blog. He and all the people with privileges can edit that info, the other can only read and post comments as

Support for nested model and class validation with ASP.NET MVC 2.0

巧了我就是萌 提交于 2019-12-07 02:15:00
问题 I'm trying to validate a model containing other objects with validation rules using the System.ComponentModel.DataAnnotations attributes was hoping the default MVC implementation would suffice: var obj = js.Deserialize(json, objectInfo.ObjectType); if(!TryValidateModel(obj)) { // Handle failed model validation. } The object is composed of primitive types but also contains other classes which also use DataAnnotications. Like so: public class Entry { [Required] public Person Subscriber { get;

Properly registering JavaScript and CSS in MVC 2 Editor Templates

吃可爱长大的小学妹 提交于 2019-12-07 02:10:42
问题 How do I properly register javascript blocks in an ASP.NET MVC 2 (RTM) Editor template? The specific scenario I'm in is that I want to use Dynarch JSCal2 DateTimePicker for my standard datetime picker, but this question is in general to any reusable javascript package. I have my template working properly now but it has my JS and CSS includes in my master page and I would rather only include these things if I actually need them: <link rel="stylesheet" type="text/css" href="../../Content/JSCal2

ASP>net MVC reusable partials

一曲冷凌霜 提交于 2019-12-07 01:42:44
问题 Having worked with .net in both winforms and ASP.net for a few years I am now starting to get into MVC (a little late I know). One major confusion for me is the concept of reusable 'components', similar to the concept of a usercontrol in webforms. For example, I would like to have a number of 'widgets' within the members area of my site, one of which is the details of the logged in users account manager. I can create this as a partial however when the page loads the data needs to be passed in

TempData is not clearing as expected

最后都变了- 提交于 2019-12-07 01:40:32
问题 I'm working on an application using ASP.NET 4.0 and MVC 2.0. If it's in any way relevant, I'm using VS2010. I'm running into complications with TempData. I did not write the original code, but it isn't working correctly and I'm attempting to fix it. I don't have a lot of experience working with TempData and ViewData. I have an Index action as follows (pseudocode): public virtual ActionResult Index() { var vm = new IndexViewModel(); // some code here to set up the ViewModel if (TempData

No styles / images on asp.Net MVC 2 application

我们两清 提交于 2019-12-07 00:55:31
问题 Greetings i have a little problem with my ASP MVC application. On my local development server everything works just fine but when i try to publish the application to an IIS 7.0 server it just displays plain pages without any styles / markups / images. I put all those things in the /Content/ subfolder but when i try to access that folder on the production server it just returns me a 404 not found error. I set the IIS server up with .Net 4.0 and followed the deployment guide on here: http://www

How to return View with QueryString in ASP.NET MVC 2?

家住魔仙堡 提交于 2019-12-07 00:52:44
问题 I'm developing a web site in ASP.NET MVC 2. At some point, I get to a ActionResult in a controller and I obviously call method return View(); Is there any way, that I could pass QueryString into my view or attach parameters to the URL? 回答1: You can try public ActionResult Index() { RouteValueDictionary rvd = new RouteValueDictionary(); rvd.Add("ParamID", "123"); return RedirectToAction("Index", "ControllerName",rvd); } Don't forget to include this using System.Web.Routing; or simply you can

ASP.NET MVC 2 - “The model of type 'XYZ' could not be updated” when using UpdateModel and LINQ to Entities (.NET 3.5)

坚强是说给别人听的谎言 提交于 2019-12-06 23:14:14
问题 I have a model set up using LINQ to Entities and have code working that adds to the database as expected. However, I can't get UpdateModel to work when I am using .NET 3.5. [HttpPost] public ActionResult Edit(Site.Models.XYZ xyz) { try { var original = db.XYZ.First(u => u.id == xyz.id); UpdateModel(original); db.SaveChanges(); return RedirectToAction("Index"); } catch (Exception ex) { return View("Error"); } } This results in the following exception: System.InvalidOperationException was

Difficulty Ignoring Route In Asp.Net Mvc

谁说胖子不能爱 提交于 2019-12-06 21:57:35
The following exception is being thrown after an IgnoreRoute method call: The controller for path '/anything.php' was not found or does not implement IController. However, I have the following method in my MvcApplication class: public static void RegisterRoutes(RouteCollection routes) { routes.RouteExistingFiles = false; routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{*php}", new { php = @"(/?.*/)*\.php$" }); // Some calls to routes.MapRoute occur here. } I'm not really sure why the exception is being thrown if the Mvc website is set up to ignore such routes. Also, I'm

MVC .NET Create Drop Down List from Model Collection in Strongly Typed view

狂风中的少年 提交于 2019-12-06 19:53:37
问题 So I have a view typed with a collection like so: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IList<DTO.OrganizationDTO>>" %> The OrganizationDTO looks like this: public OrganizationDTO { int orgID { get; set; } string orgName { get; set; } } I simply want to create a Drop Down List from the collection of OrganizationDTO's using an HTML helper but for the life of me I cant figure it out! Am I going about this the wrong way?