asp.net-mvc

ASP.NET MVC: where to keep entity being edited by user

Here's a simple problem: users want to edit products in grid-like manner: select and click add, select and click add... and they see updated products list... then click "Finish" and order should be saved. However, each "Add" have to go to server, because it involves server-side validation. Moreover, the validation is inside domain entit...

Bind formValue to property of different name, ASP.NET MVC

I was wondering if there was a way to bind form values passed into a controller that have different Id's from the class properties. The form posts to a controller with Person as a parameter that has a property Name but the actual form textbox has the id of PersonName instead of Name. How can I bind this correctly? ...

How can I read an uploaded Excel file and save it direct to DB?

Hi! Is there a way to upload an Excel file and save its content to Sql Server directly? thanks!! EDITED: I don't want to save it as binary. I want to read its contend and save them to DB, each Excel column content into the DB table column and so on... ...

Persisting Selected Value in MVC DropDownLists

I'm new to MVC, but I've been all over this, read all the documentation and all the questions and all the blog posts I can find, and all I'm doing is getting completely wrapped around the axle. I'm trying to make a "create" Action and View. My data entry is relatively straight forward, and common: I have a drop down list and a text box....

Table row not updating correctly using MVC Ajax

I have a table with each row as an ascx. This control consists of a Ajax form which includes cells which might have inputs. Here is the ascx: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<NerdDinner.Models.Dinner>" %> <% using (Ajax.BeginForm("ViewAll", new AjaxOptions {UpdateTargetId = "Dinner" + Mod...

What is the proper way to do multi-parameter AJAX form validation with jQuery and ASP.NET MVC?

I have a registration form for a website that needs to check if an email address already exists for a given company id. When the user tabs or clicks out of the email field (blur event), I want jQuery to go off and do an AJAX request so I can then warn the user they need to pick another address. In my controller, I have a method such as ...

Spark view engine - passing model to partial view

It would like to iterate through list and render partial view for each element: <for each="Element elem in elements"> <render partial="partialViewName"> </for> How should I pass elem to partial view? <render partial> doesn't have additional parameters. I can use html.RenderPartial, but I would like to use Spark syntax. Is it po...

ASP.NET MVC Error Handling - View never renders, Web.config problem?

I have a [HandleError] attribute specified atop one of my controllers, specifying a View that I'd like to render in the event of an error. I also have the following config section in my web.config: <customErrors mode="On"> <error statusCode="404" redirect="~/Error/NotFound"/> <error statusCode="500" redirect="~/Error/Unknow...

.net MVC, SelectLists, and LINQ

I am new to using the Html.DropDownList in the MVC framework and am having a hard time understading how to select the data out my database to bind to the DropDownList. Is there an easy way to return a bindable list (such as a SelectList) from a standard LINQ query? ...

asp.net mvc migration from vs 2008 to vs2010

i am trying to open my vs 2008 solution in vs 2010 beta 2. it converted the solution file and brings in the unit test project but it can't seem to bring in the main project. it kicks off the vs conversion wizard and says that it completed successfully but the project doesn't show up. has anyone seen this? any suggestions? ...

migrate a asp.net mvc solution file from 2010 back to 2008

i did an upgrade and it caused lots of problems. unfortunately i didn't back it up. Is there anyway i can convert a 2010 solution file back into asp.net mvc 2008? ...

ASP.NET MVC routing issues

I'm having some issues trying to setup my Routing in MVC. I think I understand how it works, but I just can't seem to set the proper paths. Basically I want to do something similar to how StackOverflow works so: http://localhost/faq I want this to grab the HomeController, hit the faq action and return the faq view. I can't seem to f...

Create Dynamic pages in asp.net mvc

I need to integrate the functionality of creating dynamic pages (like google sites) to my regular asp.net mvc(C#) application. I like to write my own code with database. Any suggestions or reference for this? ...

ASP .NET ajax field validation

Hello, What would be the easiest way to have the color of a text field in an ASP .NET MVC form changed according to a value just entered BEFORE form submission. The color to be used is returned by a DB query. For example: The query returns Red if the number enter in the field is lower then the Quantity registered for the item in the ...

Asp.Net Axaj.BeginForm & UpdateTargetId not working

Hi, I have this in HomeController: public ActionResult Details(string id) { var customer = Customers.GetCustomersById(id); return PartialView("CustomerDetails", customer); } And this in Index.aspx: <div> <% using (Ajax.BeginForm("Details", new AjaxOptions { UpdateTargetId = "...

DRY in the MVC View

I've been working a lot with asp.net web forms and one think that I like about the is the consistency with the generated markup e.g. if you create a composite control for a TextField you can control the generated markup in a single class like and don't break the SRP: <form:textfield id="firstName" runat="server" required="true" label="F...

Keeping jquery/javascript separate from asp.net MVC views?

Hi there, I am trying to found it the best way to keep my scripting i.e. jquery/javascript separate from my view (html) in asp.net MVC... Does anyone have any idea the best way of doing this?? I am seeing alot of code smell in my views ... I have used in the past JavascriptMVC which does a really good job and maybe its a good idea ...

PreCompile ASP.net mvc

Hi, I believe you can pre compile a asp.net mvc application but there are some issues with aspx files. Is it correct to say the view folder needs to be copied to the deployed location? If so does anyone know why? Thanks ...

How to access Model.Something value in ASP MVC at View's javascript section

Hello, I would like to access a Model property value in ASP MVC at the View's javascript section What is the best way to do so? Thanks ...

Routelink viewdata value is always null

I have a routing rule routes.MapRoute( "Search", // Route name "Restaurant/AdvancedSearch/{foodType}", // URL with parameters new { controller = "Restaurant", action = "AdvancedSearch", foodType = "" } // Parameter defaults ...