asp.net-mvc

How can I add a class attribute via Html.BeginForm?

Hi, I know I can specify form attributes this way: Html.BeginForm("DoSearch", "Search", FormMethod.Post, new { id = "MyForm"})) But what about class attributes? Obviously this does not work: Html.BeginForm("DoSearch", "Search", FormMethod.Post, new { class = "myclass"})) I've also tried new { _class = "myclass"} and new { c...

ASP.NET MVC - Controller parameter not being gathered from form?

We are having this problem with a controller right now; the controller looks like this: public class AccountsController:Controller { public ActionResult List(int? page, int? pageSize, string keywords) {...} } We are posting to this page via jquery: $.post("/myapp/Accounts/List", {"page":0,"pageSize":10,"keywords":"asdf"}, ...

ASP.net MVC, display a view from another controller

Is it possible to display a view from another controller? Say for example I have a CategoriesController and a Category/NotFound.aspx view. While in the CategoriesController I can easly return View("NotFound"). Now say I have a ProductsController and an action and view to add a product. However, this action requires that we have a Cat...

Extending AccountController: ASP.Net MVC Membership

The ASP.Net MVC 1.0 (Final) project template has basic Membership built in, but I need to extend it in two ways: Email Confirmation to validate new accounts. Additional fields on the registration view, such as "Home Street Address" and "Department Number" I am planning to modify the template files such as Controllers/AccountControl...

LinkButton in ASP.NET MVC

I need to instantiate some ASP LinkButtons onto an ASP.NET MVC view page. I've tried a few things, and I cant get them to come out right. Heres my most recent incarnation of the code: the aspx file <body> <% using (Html.BeginForm("TitleDetail", "Movies", FormMethod.Post, new{runat="server"})) { %> <ul> <% foreach (var disc i...

xVal and the ViewModel pattern - can it be done?

I've been adding xVal to the NerdDinner app - so far so good, I get client-side validation with jQuery.validate in one line, which is truly beautiful. But I can't seem to get xVal to validate a complex object. Say I have a Dinner object that looks like this: public class Dinner { [Required] public string Title { get; set; } } ...

Display image from database in asp mvc

Im getting a image in a byte array format from the controller, how i can display this in the view? in the simplest way. ...

My ASP.NET MVC application is Anemic.

I read Fowlers description of Anemic Domain and I believe I have those symptoms. I have several objects doing nothing but passing data around in different packages. I also have several Services that pretty much handle all the behavior (executive functioning). I am starting to lose track of why and what i did and where to find certain tas...

What is ModelState.IsValid valid for in ASP.NET MVC in NerdDinner?

On the NerdDinner example of Professional ASP.NET MVC 1.0 there's a method to create a new dinner as copied bellow (page 89 of the free NerdDinner version). There it checks ModelState.IsValid for true. It seems to check if the model is valid for the database (that is, it catches data type conversions, like dates with invalid format, but...

ASP.NET MVC: Is a helper allowed to grab data?

All my controllers in my project inherit from a base controller, which has a property with my Entity Model. Let say I have a view that shows cities in the world, and it has an option to filter by country. The country filter is a dropdown list of countries from the database. The Html helper for the dropdown list requests a IEnumerable<Se...

How do I get database validation among my rule violations on ASP.NET MVC?

On the NerdDinner example a set of business rules are written to validate the data on a model. Things like empty strings are checked for and by calling modelObject.GetRuleViolations() you can get them all. But there's another layer of validation which is the database. For example, the datetime field is left for validation to the database...

(Frustration) Finding the right way to create portal-like site (with portlets) in ASP.NET MVC

My mind is really going to explode and I am so frustrated. I have been searching the net for 1 week now about this and I see a lot of contradiction on the subject and I don't know which method is the right one. some people like in this article say use <%=Html.RenderUserControl("~/Gravatar/GravatarImage.ascx")%> but in comments people...

ASP.NET MVC: Partial class: Cast Model to Generic class?

I'm building a generic grid to use in ASP.NET MVC applications. I'm having troubles with making a partial view that gets a generic class passed to it. I have prepared a small sample project which demonstates what I want to do. Download it here. In the HomeController I have 2 controller actions that use my generic grid class to prepare ...

What technologies to use for starting up a new project? (Technology Prespective)

Hey Guys, Today I had a nice opportunity from my manager to propose new technologies to start up a new project. Here we used to use ASP.NET and SQL mainly. I really wanna propose using ASP.NET MVC and LINQ To SQL and do some nice TDD. The question is, i don't know how to convince my manager, actually i'm not sure of these choices mysel...

Modelbinding lists

I got a controller action like public class Question { public int Id { get;set; } public string Question { get;set; } public string Answer { get;set; } } public ActionResult Questions() { return View(GetQuestions()); } public ActionResult SaveAnswers(List<Question> answers) { ... } the view> looks like: <%...

Checking MVC.net is installed from Web Setup Project

Hi, Does anyone know of an elegant way to check form a web setup project (as a pre condition maybe?) that MVC.net is installed on the target machine? Is the registry the best way? Or a windows installer search? Many Thanks, ...

Reportviewer datasource in asp.net-mvc

How do I integrate reportviewer in asp.net mvc project? I want to add business objects of MVCProject.Model namespace. Reportviewer allows Business objects of DataSet. Is it possible to choose other data source? Like LINQ data source... or Direct object to LINQ-to-SQL class objects. What would be the best solution to add reports in MV...

How should asp.net(mvc) server return error to jquery ajax call to be caught in error callback?

Suppose I have a method in my controller that is called via a jQuery AJAX call. E.g. I'd like to delete a user. When everything goes fine, I return new Content('ok') and exit the method. What should I do when an error occured? I'd like to indicate it by an appropriate status code, so that my error call back would be called called. Why s...

Having problems with Attributes and DotNetOpenID

Hi folks, i'm trying to set up my code to request some attributes from the OpenID Service Provider. At the same time, I wish to return an ActionResult. Here's the code in the OpenId sample MVC project (that comes straight out of the DotNetOpenId / DotNetOpenAuth website) ... try { return openid.CreateRequest(Request.Form["openid_i...

How do I moq a ISingleResult? Should I? or there is a better method?

I have an action method like this in my controller public ActionResult Index() { using (NorthwindDataContext db = new NorthwindDatacontext()) { var results = db.GetRecordSets(arg1, ....).ToList(); // use results as list } return View(); } and I wanted to start making tests for it (yes, after it was bui...