asp.net-mvc-2

Cannot apply foreach?

I'm trying to get a list of all area in my database: public ActionResult Index() { var carreras = repo.FindAllCarreras().ToList(); AreaRepository area = new AreaRepository(); ViewData["Areas"] = area.FindAllAreas(); //Return IQueryable<> return View("Index", carreras); } ...

Think you can make this code prettier?

Here's a simple MVC View that displays all Areas in a DB and then lists all Carreras in each Area under the header. <h2>Listado General de Carreras</h2> <% foreach (var Area in (List<string>)ViewData["Areas"]) { %> <p><span class="titulo"><%: Area%></span></p> <% foreach (var carrera in Model) { ...

How do I set my favicon?

How do I set my Favicon in my ASP.Net MVC2 application? The .ico file is already in the Content folder, now what do I do? ...

How can I create an application-wide 404 error page?

In my ASP.Net MVC2, how do I create a wide 404 page? Meaning every single time someone tries to enter a non-existent view/page, he's redirected to this error page of my choosing? ...

Does ASP.NET MVC have a Decimal route constraint baked in?

Does ASP.NET MVC have a decimal route constraint baked into the core library? I know there's the Regex Constraint but I was wondering if there's any others? ...

Upload multiple files / access input id at server site

I am trying to upload a couple of files. The upload itself works well for a single upload but I can't figure out how to access the element name to make sure each upload is assigned to the correct field. HttpPostedFileBase doesn't seem to contain that type of info anymore. public ActionResult Edit(int id, FormCollection collection) { ...

Changing scripts folder in MVC application and using Telerik MVC Extensions

I am using the Telerik MVC Extensions and have moved my Scripts folder in to the Content folder. So instead of ... <script src="<%= Url.Content("~/Scripts/jquery-1.4.1.min.js") %>" type="text/javascript"></script> ... I now have ... <script src="<%= Url.Content("~/Content/Scripts/jquery-1.4.1.min.js") %>" type="text/javascript"><...

ASP.Net MVC - Is this entity layer a step too far?

I have a domain data model which returns a class such as the following: public class ZombieDeath { public virtual int ZombieId {get;set;} public virtual FatalHit {get;set;} } public class FatalHit { public virtual int HitId {get;set;} public virtual string Zone {get;set;} public virtual string Weapon {get;set;} ...

dotnetopenauth and ajax forms

I'm trying implement an openId login with Google account together with ASP.NET MVC 2 framework and DotNetOpenAuth library. The following code is used to render login button: <% using (Html.BeginForm("LogOnPostAssertion", "Authentication", FormMethod.Post, new { target = "_top" })) { %> <%= Html.AntiForgeryToken() %> <%= H...

ASP.NET MVC2 depends on which version of the .NET Framework?

ASP.NET MVC2 depends on which version of the .NET Framework? ...

ASP.NET MVC AJAX with HTML.ValidationMessageFor

Hello, I'm used to the ASP.NET Webforms easy way of doing AJAX with UpdatePanels. I understand the process is much more artisanal with MVC. In a specific case, I'm using Data Annotations to validate some form inputs. I use the HTML.ValidationMessageFor helper to show an error message. If I want to use AJAX to post this form and show thi...

NullReferenceException on code that should work.

I have the following controller Action: public ActionResult Details(int id) { Seguimiento seguimiento = repo.GetSeguimiento(id); if (seguimiento == null) { return View("NotFound"); } else { return View("Details", seguimiento)...

How to store additional user data using MembershipProvider/FormsAuthenticationTicket?

I have implemented my own custom MembershipProvider with a custom data store. No problems so far. I would like for people to login using their email instead of a username. Because I have my own data store, this is not a major issue, I can just pass the email as the username for the MembershipProvider. My question is, how do I store addi...

ASP.NET MVC 2.0 Tutorial (Like Nerd Dinner)

Are there any tutorials like Nerd Dinner but for MVC 2.0? I've seen MVC Music Store but I'd prefer something that moves a little more swiftly. If not, are there any reccomendations for more advanced tutorials that go over specific topics? Side note: I really liked the style of the NetTuts CodeIgniter Series. Something like that but for...

The ViewData item that has the key 'IDMateria' is of type 'System.Int32' but must be of type 'IEnumerable<SelectListItem>'.

I have the following code in my Simulacion controller: [Authorize] public ActionResult Create() { Simulacion simulacion = new Simulacion(); MateriaRepository materia = new MateriaRepository(); EvaluadorRepository evaluador = new EvaluadorRepository(); ViewData["Materias"] = new SelectList(materia.FindAllMaterias().ToLis...

Date Range Validation Error

We are using MVC Validation Model to do both client and server validation. On the client side, we are using jQuery. Everything works great except the jQuery that is produced to validate a date range. We are always getting the error message displayed that says the date entered is not within the range. Here is what I have: Relevant Model ...

Disable Delete in Asp.Net Dynamic Data for One Table but Allow Insert

Hi I have a site where I use a User Table. I want to be able to add users but not delete them - I need to update a filed in the database that said Is Deleted - Any Idea how to do this? ...

DropDownList does not get selected using with HtmlHelper.DropDownListFor

Hi all, I render a dropdown list to allow the user to select the enum value using this solution http://blogs.msdn.com/b/ukadc/archive/2010/06/22/asp-net-mvc-creating-a-dropdownlist-helper-for-enums.aspx. this is the helper public static MvcHtmlString EnumDropDownListFor<TModel, TEnum>(this HtmlHelper<TModel> htmlHelper, Expression<Fun...

How should I handle multiple buttons in my action?

I have a form like this: <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <% using (Html.BeginForm("Edit", "Order", FormMethod.Post, new{id="EditForm"})) {%> <input type="hidden" id="ButtonAction" name="ButtonAction" /> <div id="orderbuttons"> <div id="previous"> <input type="image" name="BtnIma...

Any downside saving shopping cart in Profile? Profile Migration?

I'm doing some research for my project where I'm gone have a shopping cart. I been reading some and one way that shopping cart seem to be handled in mvc is to save it to the Profile and later on save it in the db after order is complete, and [Serializable] on the class. My question is do you see any downside doing it like this with the ...