asp.net-mvc

HttpContextBase type not found in VB.NET (using Rhino Mocks with ASP.NET MVC)

I'm trying to implement the GetHttpContext function from HtmlHelperTest.cs in VB.NET using Rhino Mocks, but I'm getting "Type 'HttpContextBase' is not defined." The compiler suggests changing it to HttpContext, but when I do that I get a run time error that a sealed class cannot be mocked. My test project references System.Web and also ...

jQuery - ASP.NET MVC - .load and RenderPartial

For some specific reasons, I need to use the jQuery 'load()' method in order to feed a webpage into a div layer. Most of these webpages are plain .html files. However for some, there is some data processing going on - I would like to be able to leverage the ASP.NET MVC model (which the site is built in) - but that's not possible with ...

Asp.Net MVC 1.0 custom Modelbinders - how to handle form posts and parameter names?

I have a custom model binding: using System.Web.Mvc; using MyProject.Model; namespace MyProject.ModelBinders { public class VersionedIdModelBinder : IModelBinder { public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { //Not completely happy with this. Wha...

How can I refactor this Validation?

Hi I have a validation class that implements IDataErrorInfo that has all the methods that you must implement. One is public string this[string columnName] { get { } } return ""; Now in this switch statement I have some validation for my form. Now I noticed lots of my for...

Entity Framework to multiple databases (same schema) at runtime?

First of all, let me state I'm very new to EF. With that said, here's my dilemma: There will be an ASP.NET App migrated to ASP.NET MVC. I would like to utilize EF for this. There is one main database which stores "client information". Apart from that, every "client" has their own database. These are the constraints we have. Currently, ...

RedirectToAction with parameter

I have an action i call from a anchor thusly, Site/Controller/Action/ID where id = an int. later on I need to redirect to this same Action from a Controller. Is there a clever way to do this? Currently I'm stashing ID in tempdata, but when you hit f5 to refresh the page again after going back, the tempdata is gone and the page crashes...

UI Patterns for ASP.NET MVC

MVC practically begs to create pages that are organized into clear areas of responsibility. So instead of a single page with two or three editable grids that allow in-line changes to their lists, in MVC one is more likely to get a specific edit page per line item per grid. For that matter one is very unlikely to see the type of page th...

ASP.NET MVC - "Add View" Outside of the Views Folder

Are there any changes I can make to Visual Studio to add the "Add View" dialog option to a folder other than Views? I have my website split up somewhat differently and I'd still like access to the T4 templates provided by "Add View". To clarify: I am not trying to change the default View Engine or do anything in code pertaining to how ...

ASP.NET MVC - Sharing Session State Between Controllers

I am still mostly unfamiliar with Inversion of Control (although I am learning about it now) so if that is the solution to my question, just let me know and I'll get back to learning about it. I have a pair of controllers which need to a Session variable, naturally nothing too special has happen because of how Session works in the first...

Having problems with Asp.net MVC Unleashed Generic Repostitory

Hi I just got this book In it there is a .dll for a generic repository. I followed what he did but I always get a error. System.InvalidOperationException was caught Message="The EntitySet name 'MyEntities.CarSet' could not be found." Source="System.Data.Entity" StackTrace: at System.Data.Objects.ObjectContext.GetEntitySet...

Binding values doesnt work

Hello I have a model that looks like this: public class UserAdminEditViewModel { public User User { get; set; } public IEnumerable<Usergroup> Usergroups { get; set; } public IList<int> UsergroupID { get; set; } public UserAdminEditViewModel() {} } And my View looks like this: <%@ Page Title="" Language="C#" MasterPa...

Form input validation options in ASP.NET MVC 1.0+

A number of questions have been asked on this topic before, but since ASP.NET MVC is moving quite fast I wanted to re-ask the question: What would you recommend for providing form input validation in ASP.NET MVC? Requirements: Server-side checking Client-side (JavaScript) checking Should cover the basics such as mandatory fields, num...

Populate EntitySet from List<int>

Hello I have a model that looks like this: public class UserAdminEditViewModel { public User User { get; set; } public IEnumerable<Usergroup> Usergroups { get; set; } public IList<int> UsergroupID { get; set; } public IEnumerable<User> Users { get; set; } public UserAdminEditViewModel() {} } And in my post-action...

Using LINQ2SQL and MVC for wizard-type save functionality

Hi, I have an ASP.NET MVC application that uses LINQ2SQL as the database layer. I can save data back to the database no problem but I've came across a few issues when trying to save using a wizard-type scenario where data is collected over a few different forms but not saved to the database until the last form "Save" button is clicked....

HtmlHelper missing?

I'm trying to create an Html Helper, by creating a static class as follows: public static string Crumbs(this HtmlHelper helper, params string[] args) where T : class { // ... rest of code goes here. } And I'm invoking it like this: <% Html.Crumbs( Html.ActionLink("Home", "Index", "Home"), Html.ActionLink("Lists", "Index",...

Why ASP.NET MVC favorites Linq to SQL over LINQ to Entities?

The question is in the title. ...

ASP.NET MVC Model/ViewModel Validation

I have model classes in Linq-to-Sql with partial classes marked with data annotation attributes and a reference to xVal. When I bind a view directly to a model everything works great, both the JS generated by xVal and server side double check. Many of my views don't take input to one specific model, so I am setting up view model cl...

Integrating ASP.NET-MVC with Silverlight using WCF and Ninject as IoC/DI

I have a prototype ASP.NET-MVC website which uses Ninject as a IoC container. All service-classes and repository-classes used by MVC Controllers are properly injected by Ninject. This is great. The next thing I need to add there is Silverlight (version 3 to be more precise). Silverlight will be connecting to my server using WCF service,...

Providing data to Menu in my ASP.NET MVC Master Page

We are beginning the process of moving from Web Forms to MVC for all of our new applications. I am working on porting our Master Page over and am trying to satisfy the requirements that we need a single master page to be used by all applications. The primary navigation for the application needs to be in a menu within the master page. Ac...

Jquery Tabs in a MVC User Control

I am having a problem with Jquery Tabs. On my MVC page, I have a form that returns a partial page (.ascx). This page has Jquery tabs on it, howerver all I get is the tab content without the tab. It looks like the partial page javascript code for the tab does not run, <script type="text/javascript"> $(function() { $("#tabs").tabs(); ...