asp.net-mvc

Writing Unit Tests in ASP.Net MVC with Code-First and EF4 and SQL CE4

Hi All I've been reading Scott Gu's post on code first design with ASP.Net MVC 2.0 and EF4 here: http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx In the post he uses the SQL CE4 database for development and 'seeds' test data. My question is related to testing. It is widely regar...

Invisible caching in ASP.Net MVC

I'm creating a page that has some dynamically generated images built from data that comes from web services. The image generation takes a fair amount of time due to the time involved in hitting the web services, so I need to do some caching. One option would be to use the OutputCache parameter to cache the images, but I don't like forci...

ASP.NET MVC 2.0 Go previous page submit button. Possible solutions. Opinions

I have kind of wizard application and i need to have back button to allow users after clicking on this button to go back to previous step if they would like to change something in previous steps. 1) I may do this using JavaSript onClick=“history.go(-1). 2) I may do this using submit button to redirect to previous action: 2.1) i may ha...

MVC client validation causing false errors

I'm hoping someone has run into something similar. A text input with text is triggering the client-side [Required] error message. I have the following included in the master: <script src="/Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script src="/Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script> <script src...

Using Microsoft Office Interop to create and parse Excel spreadsheets from ASP.NET.

I have a new ASP.NET MVC project that has two requirements that require using the Office Interop DLLs to generate Excel spreadsheet files in Excel 2003 format by combining several template files into a multi-sheet workbook and to parse these files once filled in. The files we parse may come back in Excel 2003, 2007 or 2010 format (I beli...

Nhibernate (and ORMs in General): work with Objects or ObjectIds?

This is something that has been pulling at me for a while. Consider a (MVC type) web application with an ORM (e.g. Nhiberate) as the data access layer. On one hand - the OOP/Rich domain model hand - I feel I should be passing around (references to) the real objects I am talking about. On the other hand - the DB/Web App hand - I feel ...

Merge an Object that wen outside the datacontext

Hi, I have the following question: It is easy to insert an oBject in database with a form. Just create an object link it to the fields in your from. Post back to controller, create a new datacontext and do datacontext.InsertOnSubmit(object) . public static void AddPage(string lang, Page page) { ...

Why is this simple jQuery not working?

I have this jQuery get request: $.get($(this).attr("href"), { "searchExpression": "schroders" }, function (result) { // do stuff }, "html"); Which sends the get request to this Action Method: public PartialViewResult Tabs(string searchExpression) { return PartialView(new SearchViewModel { PagedFunds = _fundServi...

ASP.NET MVC - Help defining route entry

i want to build a route entry for a url http://example.com/foo which should map to Index(string foo) action method of a controller named User. At the same time the default Home Controller should not be affected and should work normally any help is greatly appreciated Thanks ...

MVC 2.0 Validation Summary groups

I have 3 portals on the view (one form) with one submit button. I need to have validation summary for each of this portals. Is there any way have validation groups fro summary validations like in asp.net? I was thinking that if i put Htm.Validation Summary on each portal it will validate only inputs for this portal, but it is not, all Va...

Add another propertymapping? (AutoMapper)

Can you Mapper.CreateMap<Foo, Bar>() .ForMember(x => x.IsFoo, x => x.Ignore()); and then later on add another mapping of the sort .ForMember(x => x.IsBar, x => x.Ignore()); or even change the old one .ForMember(x => x.IsFor, x => x.MapFrom(z => z.IsBar)); ? If so, how? ...

How to send jQuery $.get so the Model Binder can bind a string to a parameter?

I'm having difficulty getting the Model Binder to work. I thought it was the jQuery, so I asked this question, but after further investigation, I can see that the jQuery is indeed sending the parameter to the server. That's the reason I'm asking a new question - this is no longer a jQuery issue, as I originally thought. Background: Wha...

Html Helpers generates ID from model properties. How do I target 1 particular element with JavaScript and CSS if many elements have the same ID?

Hello, As it's recommended, Javascript must be kept in a physically separate file (to be unobtrusive). So how do I access a particular element in particular page? should I detect those elements by id? that would mean 2 elements can't have the same id even if they are not located in the same page. Well, for instance, using the Html help...

Does using ViewModels and references to System.Web.Mvc violate the MVC pattern?

I've seen it all over SO, blogs, and books, where the authors tell you add ViewModels specific to your View in your Model projects as wrappers for your underlying model objects. The idea is to make it very simple and targeted when you go to do model binding to the View. Here is a good example: Rendering and Binding Drop Down Lists using ...

Visual studio refactoring a property of a viewmodel does not reflect in the View?

I have a simple ViewModel class like public class TestViewModel { public String Information { get; set; } } My View inherits from it and I got Intellisense kicking in. So far so good. I have written these for tests in the View: <%= Html.Encode(Model.Information) %> -- <%= Html.Label("Information") %> -- <%= Html.LabelFor(m => m....

How many Ajax libraries/frameworks are in the mainstream right now?

I'm trying to learn ASP.NET MVC and your first reaction might be to tell me I don't need to learn all the Ajax stuff to learn MVC. Fine, I get it. But I am not very confident if I don't know what's going on around me, i.e. in the environment surrounding my code. Since my goal is to learn ASP.NET MVC, I first tried some examples, watched...

Which is the preferred method of starting a form using HTML helpers??

<% using(Html.BeginForm()) { %> ... <% } %> OR <% Html.BeginForm(); %> ... <% Html.EndForm(); %> What are the advantages/disadvantages of using both ways to use Html.BeginForm? ...

GPL 2.0 Free Telerik Extensions for ASP.NET MVC

Is my ASP.NET MVC project automatically GPL 2.0 licensed by including these libraries? I always find this confusing with the GPL. ...

Linq-To-Sql, MVC, Enumerable results with Distinct query

I'm very new to .Net C# and I really don't have a clue as to what I'm doing wrong. I have a LinqToSql DataContext I'm drawing distinct results from, but I'm not sure how to properly output the results in my view. I'm getting a compilation error (Compiler Error Message: CS1002: ; expected) on my view. StoreRepository.cs public IQuerya...

ASP.NET MVC: How to convert View Model into Json object.

I am Java developer new to .NET. I am working on a .Net MVC2 project where I want to have a partial view to wrap a widget. Each JS widget object has a JSON data object that would be populated by the model data. Then methods to update this data bound to events when data is changed in the widget or if that data is changed in another widge...