asp.net-mvc

ASP.NET MVC - Mixing Custom and Default Model Binding

Hello, I have a type: public class IssueForm { Order Order {get; set;} Item Item {get; set;} Range Range {get; set;} } I created a custom model binder due to requirements on Order and Item, but Range could still use the Default Model Binder. Is there a way from within my custom model binder to call the default model bind...

jqGrid and ASP.NET MVC URL posting problem

Hi all, I have a problem with jqGrid and ASP.NET MVC framework. Namely, jqGrid is working fine, until the point when I have in address bar URL like this: http://[domain]/Controller/Action It gives me JS error: "Object doesn't support this property or method". When URL is like this: http://[domain]/Controller everything is working...

MVC -DropDownList - Categories - SubCategories

In my database I have tbales: categoreis and SubCategoreis. I would Like to create one Dropdownlist containg both of these. Something like: Välj <option value='1000' style='background-color:#dcdcc3;font-weight:bold;' id='cat1000' > -- FORDON -- /// this is from Categoreis Table </option> <option value='1020' id='cat10...

ASP.NET MVC - Intellisense doesn't update model

Firstly, I've done a build, I've done a clean, I've done a rebuild, of both the project and the solution, so that's not the problem. When I change my model for some reason the intellisense (in fact, it's not just the intellisense as if I do a build it comes up with an error as well) doesn't work. I have a model under ViewData.Model.Con...

Post: Bind Models

In my Database I have Members Table and Pictures tables. A Member can have 1 to many Pictures. When Post has been made the member.Picture.Count = 0, I can't understand Why? and How should I solve this? What Iam doing is: public ActionResult Create() { Member member = new Member(); Picture pic = new Picture(); ...

ASP.NET MVC: How too keep orignal object state over the wire

Consider the following code: public ActionResult Edit(int id) { return View(db.Foos.Single(x => x.Id == id)); } When user submits the changes, I would like to receive both original and current object values, such that the Update code can be: Foo foo = db.Foos.Attach(current, original); db.SubmitChanges(); I see two options: 1)...

MVC Model issue can you diagnose what this is saying?

This is part of the first build repoistory that sits on Microsoft MVC. First call from the controller down for model. public ActionResult Index() { var prog = yRepository.FindUpComingProgrammes(); return View(prog); } ASP ERROR: Server Error in '/' Application. -------------------------------...

ASP.NET MVC Custom Authorization

I have a question about custom authorization in MVC. I have a site that I want to limit access to certain pages, depending on their group membership. Now I have seen tons of examples on how to do this if there is a single admin group and a single user group, for example, but not any examples for a third level. For example, only user...

Build link using expression in controller

I would like to be able to build a link to a controller action inside of my controller. I really want to do something like: <%= Html.BuildUrlFromExpression<Controller>(x => x.ActionName(param)) %> ...except in the controller. Any way to do this? ...

What are the recommended datagrids for asp.net mvc?

I have looked at a few data grids for an asp.net mvc app I am developing. I would like to get some opinions on the different datagrids for asp.net mvc. I would like to know the pros/cons with the data grid, if you care to share. ...

ASP.NET MVC and text/xml content type

I want to return a View() from an action, and the resulting response should have a content type of text/xml instead of the default text/html. I have tried the following, with no success: Response.Content = "text/xml"; return View(); I know that you can specify the content type by returning ContentResult, but that doesn't render my V...

How do I unit test an ASP.NET MVC controller that uses DotNetOpenId?

I have an AccountController whose constructor takes an object derived from my custom IOpenIdAuthentication interface. By default, this is an OpenIdAuthenticationService object that wraps an OpenIdRelyingParty. The interface looks like this: public interface IOpenIdAuthentication { IAuthenticationResponse Response { get; } IAuthe...

Adding a "previous" link

What the appropriate way to do this? ViewData["PreviousPage"]=Request.UrlReferrer.PathAndQuery; this doesnt work if directly accessing. EDIT: I did a null check on Request.UrlReferrer, seems to be fine (?) ...

Ad-hoc override of ASP.NET maximum request size

Is there a way to override the maximum request size for a specific ASP.NET/ASP.NET MVC page, without also changing it for the rest of the website via Web.config? ...

Why is my DataContext null in only one action?

I have a property on my BaseController called DataContext that holds my LINQ to SQL data context (or fake context for testing). When using a parameterless constructor (in other words, when a request to ASP.NET MVC is made), a new instance of my LINQ to SQL data context is assigned to the property: public class BaseController : Controlle...

How to Donut Cache a Partial View on Site.Master?

I'm trying to use donut-caching on the Site.Master page for things like the User Login and Shopping Cart, so that we can put OutputCache on some of the more resource intensive pages in our app. Currently, I'm using the tag and then writing out the html from the static method in the code behind. <asp:Substitution ID="Substitutio...

ASP.NET MVC Default route?

I created a new ASP.NET MVC project and implemented a site authorization filter. When I map the routes to the {controller}/{action} pair, I pass a role = "SomeRole" default to the route. It works perfectly if I go through the full url (http://localhost/somecontroller/someaction) and I specified the full route [ MapRoute("SomeAction",...

What characters do I need to escape when returning HTML in my JSON array?

returning HTML in my json array, what things do I have to escape for? ...

ASP.NET MVC + LINQ to SQL or Entities?

When linq to entities was released, everybody say that linq to sql is dead. But most books and sample projects by microsoft employees, use mvc+linq to sql. There is some reason for that? The linq to sql seems better for POCO, would it? ...

Validate unique keys with asp.net mvc and linq to sql?

I have a sql server table with 2 fields, ID (primary key) and Name (unique key). I'm using linq to sql to produce model objects for asp.net MVC from this table. To perform the model validation I've implemented IDateErrorInfo in a partial class public partial class Company : IDataErrorInfo { private Dictionary<string, string> _error...