asp.net-mvc

Which is the best pattern for ASP.Net MVC?

We are starting up a new project in ASP.Net MVC, could you please suggest which is the best? I have added this question as to know what are the different options. ...

Can I get a partial view with a query in ASP.NET MVC?

Is it possible to grab a partial view with a querystring? Such as <%Html.RenderPartial("MyPartial/5")%>? ...

SharePoint and MVC

Has anyone had any success with SharePoint and MVC, are Microsoft going to support this going forward in 2010? ...

SelectListItem not selected even when explicitly set to true

This question relates to ASP.NET MVC 2 RC (December drop). The basic problem is that when creating a drop down list with a default selected value, the "selected" attribute is either not rendered to HTML or attributed to the wrong option. Here's some code to demonstrate the wrong option issue: Here's a function to generate some values ...

ASP.NET MVC 2 RC Caching Problem

Since upgrading from mvc 2 beta 2 to rc I'm having trouble with an ajax submission in Internet Explorer. Upon carrying out a jquery form post, the function returns a url to a controller action. This worked fine with the controller action picking up it was a ajaxrequest and then piping back a partial view to update the page. This still...

Change default controller actionresult

Hi guys, By default ASP.NET MVC uses ContentResult for controller method that return result not inherited from actionresult type. That is why if we will return some poco entity it will be only its type name. Could I overload something in controller to make it return jsonresult by default. Example: // return json product representatio...

Replacement for ScriptManager when aiming for Ajax History functionality

When you are creating a Search for your Website, you Want the user experience to be as good as anytime and when you are browsing your gridview you want to be able to press the Back Button to go back to the previous viewed page. In asp.net with asp.net ajax it's possible when using the ScriptManager + Ajax Control Toolkit where there is ...

Ideas for a generic WCF Result for Asp.Net MVC

First a bit of background: We have a growing RESTful service layer supporting web pages, gadgets and now the iPhone. These have been implemented in WCF using WebServiceHostFactory to expose JSON and XML endpoints, and we now have a nice backend for easily adding new REST endpoints for other areas of the business after a process of fa...

In MVC 2, how to annotate a class for an UI Helper Template (not a property)?

I know this works for single properties as per Scott Guthrie's blog to auto-magically use a partial view to render a partial model passed to it (UI Helper like in dynamic data): [UIHint("StateDropDown")] public string State { get; set;} But how do you annotate an entire class to use an UI helper like this: [UIHint("Address")] public ...

ASP.Net MVC view dropdownlist not being binded to model after submit (post)

I have a viewmodel class for a create view that consists of 2 properties different classes, and a list of selectitems (for dropdownlist). The dropdown list and the fields for one of the classes are always shown in the view,but the fields for the 2nd class are only shown if a specific option of the list is selected. (via a jQuery load an...

For WCF, when is it necessary to statically tell a serializer about a data type?

I am using the WCF JSON serializer to produce JSON for use as return data for the ASP.NET MVC framework. I am doing this because the built-in JsonAction does not provide any way to control the naming of public properties in the serialized JSON. public override void ExecuteResult(ControllerContext context) { ... if (Data != null...

ASP.NET MVC 2 Drop Down List In Place of Master List Grid

Instead of a grid with an 'Edit' link in each row, I'd like to use a drop down list and a single 'Edit' button. What's the cleanest way to make that button direct to /Edit/{id}(i.e. the ddl selected value)? Using onclick with window.location is way too ugly, super ugly if I have to account for the url base being http://approot/ or http:/...

ASP.NET MVC - HTML Extension method building a URL or link

Consider an extension method whose purpose is to either: render an <a> tag on some condition, just return a string without a link   Question: in an extension method, how can you leverage the proper routing logic with Route Values, etc. rather than hardcoding the string. I suspect HtmlHelper.GenerateRouteLink is part of the solution, ...

Use of MVC code in jQuery

hey there - I'm trying to use asp.net mvc for some things as usual, but I've got a bit of a quandry. At one point in my application, I need to load a view and pass a specific model through it - this isn't a huge deal, except that it relates to the existing model. Now then, RenderPartial doesn't work because that only passes a model and...

MVC Master Page JQuery Document Read

I am using the JQuery UI accordion control that gets initialized in the $(document).ready() function. When moving to different views, I am seeing a flicker on this menu. Is there a way around this? ...

Securing an ASP.NET MVC application for beta testing?

Hey all. I have an ASP.NET MVC application that I am going to be deploying to a live server soon. Theoretically, I would like to password protect the application while I'm beta testing without modifying the underlying code base or membership within the application. I will have several people beta testing, so it is compulsory that it is a...

Is there an equivalent to Ruby on Rails' respond_to format.xml, etc in ASP.Net MVC?

In Ruby on Rails you can write a simple controller action such as: def index @movies = Movies.find(:all) respond_to do |format| format.html #index.html.erb format.xml { render :xml => @movies } format.json { render :json => @movies } end end For those unfamiliar with RoR, def index in this case wo...

DataAnnotation Validations and Custom ModelBinder

I've been running some experiments with ASP.NET MVC2 and have run into an interesting problem. I'd like to define an interface around the objects that will be used as Models in the MVC app. Additionally, I'd like to take advantage of the new DataAnnotation functionally by marking up the members of this interface with validation attribut...

Permissions Design

I have an application that has content that needs to be setup for permissions (i.e. member/non-member) I have roles/authentication setup just fine, that is not my issue. My question is basically asking the best way to store permissions for each object. Essentially there is "Guest" and "Member" roles, and simple "Allow" "Deny" permission...

Show a nice error view in ASP.NET MVC and still cause ELMAH to send a message

I'm using the filter from MvcContrib which causes nice error pages, my own views, to be shown when an error occurs. The problem is that when that happens, ELMAH doesn't send me an email about the problem and I still would like to know that something went wrong. It seems the key is in ExceptionContext's exceptionHandled. When set to true...