asp.net-mvc-2

Where to instantiate interface in Nunit test

I think theres something really simple I'm missing so I apologize in advance. I'm trying to test an interface with Nunit. The interface is implemented by a class derived from a base class and I'm using Castle Windsor for IOC. I simply dont know where to assign the interface in the derived test class. Here is the base test class [T...

ASP.NET MVC 2 Model Errors with Custom Exceptions

Hi Guys, I have a custom exception class: public class MyException: Exception { public MyException(MyExceptionEnum myError) : base(myError.ToDescription()) { } public MyException(MyExceptionEnum myError, Exception innerException) : base(myError.ToDescription(), innerException) { } } .ToDescription is a extension method on MyExc...

How to connect Controller to Service layer to Repository layer

Lets say I have the following entities that map to database tables (every matching property name can be considered a PK/FK relationship): public class Person { public int PersonID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } } public class Employee { public int EmployeeID { get; set; ...

A good/modern template for ASP.NET MVC 2

Hi, I'm starting a new ASP.NET MVC 2 project, but unfortunately I'm a noob dev. Can you recommend a template I can use for my web site? It would be nice if the CSS supports stuff like 3 columns, 3 rows, with up, left, down and right parts being fixed size and the center auto sizing. Actually a clean CSS template would do too. TIA ...

Displaying Custom Error page using asp.net mvc

Hello Friends, I am showing Custom Error in my page.. if somehting happend wrong. but if the same error occured in my subview master page I am not able to show the Custom error page on Entire page its showing me that Error page under subview master page. Please I am attching the Screen shot. Can any body help me out how to show the Err...

Can I call a webservice from a Controller Action in ASP.Net MVC?

Can I call a webservice from a Controller Action in ASP.Net MVC? public ActionResult Index() { PersonObject person = new Person("Sam"); //Call a webservice which is located in the same app under /Services/General.asmx/WebMethod and pass it person } Basically I want to do this from my Action... $.ajax({ ...

CSS and JavaScript in ASP.NET MVC 2 Pages

I have a master page that has two content sections like this (left some parts out): <head runat="server"> <link href="/Content/Site.css" rel="stylesheet" type="text/css" /> <asp:ContentPlaceHolder runat="server" ID="HeadContent" /> </head> <body> <div id="content"> <div id="main"> <asp:ContentPlaceHolder...

Problem with deploying asp.net MVC 2 application on XP machine

Hi I have the application which is developed in asp.net mvc 2. I am trying to deploy it on Windows XP machine which having IIS 5.1 . It is deployed fine after I add the extension to web application node in IIS . I added .* by selecting the aspnet_isapi.dll from frameworks path. I know this is not problem of IIS . It is problem of I think...

Pass more than one model to view

public ActionResult Index() { var pr = db.products; return View(pr); } Firstly - I want to pass to the view more data - something like: public ActionResult Index() { var pr = db.products; var lr = db.linksforproducts(2) return View(pr,lr); } How do I read the lr data in the view? Secondly - on the view I hav...

MVC ValidateAntiForgeryToken multi-tabs problem

Hello, We'd been getting "A required anti-forgery token was not supplied or was invalid." errors, and on some further investigation, I've managed to recreate the problem in its simplest form - i'm either doing something completely wrong, or this is a limitation of the anti-forgery token system. Either way, I'd appreciate some advice! ...

Is this possible of deployment of asp.net mvc application, without dll in iis ?

Hi, If I want to deploy my asp.net mvc application in iis (any version it may be) with code , means without any publishing. then is it must that its bin dir have the dll which is nameed by application name? Can I deploy application without its dll? ...

Custom Attributes and enumerators

Hey There I have an enum: public enum Navigation { Top = 0, Left = 2, Footer = 3 } And i have a controller action: public ActionResult Quotes() { return View(); } I would like to be able to decorate my action as follow: [Navigation.Top] public ActionResult Quotes() { return View(); } Any idea how this could ...

can't read model data on view

public class catnewModel { public IQueryable<category> dl { get; set; } public IQueryable<product> dr { get; set; } } and my controller public ActionResult Index() { var pr = db.products; var pl = db.categories; catnewModel model = new catnewModel(); model.dr = pr; model.dl = pl; return View(mode...

Is it possible to place to a conditional statement inside a Html.DisplayFor call?

Basically I have a custom built "Date" class "EndDate" in my MVC output model. FYI: The "Date" class builds of DateTime but hides the time functionality. I've created a display template for this Date type that formats the date nicely but in once instance (shown below) if the object is null (in this case for EndDate) I would like the te...

Making an ASP.NET MVC polynomial root finder

So I've just been experimenting with ASP.NET MVC and I'm really starting to like the way everything has one single purpose (as far as the separation of purpose between the models, views and controllers) but I'm still having some trouble applying my basic knowledge to a somewhat practical purpose. So, I was thinking of trying to create a...

Entity Framework 4.0 with POCO classes - Repository pattern?

Hi all, i'm writing an asp.net mvc 2 web application with Entity Framework 4.0. I have the views that should display items, views that are for login, etc. Should i structure the project with a repository pattern? If yes, how? Should i create an interface for basics methods like Add, Update, Delete, etc and another class that use the repo...

ASP.net MVC2. Populated model is not getting back to the controller.

Say I input '[email protected]' and 'password' into the login fields. The data annotations in AuthModel.cs throw back that the values aren't populated. So the data in the html form is never actually populating the model thats being thrown around. In my awesomeness, I made a lot of hurried changes yesterday before closing the solution an...

How to create an Ilist from DataTable with unknown columns.

I have a DataTable that was built from dynamically created SQL, so I do not know the number of columns in the datatable. How can I convert this datatable into an IList? EDIT: I am then going to use this to send to a Telerik Grid on the page. ...

simple MVC form post and url routing question....I hope.

I have a view called Associations that has a drop down list and a button. When the user selects an option and presses submit, I want them to go to Association/{associationKey}. Association needs to work on get and post. Currently, with the code below, when the form is posted, it DOES go to Association and displays the correct record, ...

ASP.NET MVC Int Array parameter with empty array defaults to {0}

I have a controller action like: Public ActionResult MyAction(int[] stuff){} I make a JSON request like: $.getJSON(url, { stuff: [] }) When it gets to C# it looks like an array with one element in it, which is zero (i.e. like if I did int[] stuff = {0};). Is this new with MVC 2 or .NET 4? It seems to have changed recently, but I ...