asp.net-mvc-2

How to clear validation messages and styles form modal form when closed in ASP.NET MVC

I am using a Jquery UI modal form to post data back to my action and it works fine. However when I put client side validation on and the user closes the modal without submitting the form retains the validation messages and styles. It there away to clear the validation messages and styles in JS on the client? ...

Why is the object passed to Delete action empty?

I've got a basic ASP.NET MVC 2 application. I've got adding and editing rows working just fine, but deleting won't work. The Delete view gets the correct record on the GET, but when posting back, the parameter that gets passed is empty, as in CategoryID = 0, all empty values. Because of that, no object is found to be deleted from the ...

will asp.net mvc model binder keep a posted array in the proper order?

Hello, so i've got an array of numbers that i'm posting to an asp.net mvc action that has a list(of integer) parameter and it all works great. my question is this: Is it safe to assume that the list(of integer) will have the numbers in the same order as they were in the array i posted? Thanks for your time! EDIT: The data being ...

Can't upload files with ASP.NET MVC2

I have set the enctype to: multipart/form-data yet whenever I submit this form, the Request.ContentType is: application/x-www-form-urlencoded and the contents of the upload can't be retrieved from Request.Files. Here is my View: <% using (Html.BeginForm("Import", "Content", FormMethod.Post, new { enctype = "multipart/form-data" }))...

When using .net MVC RadioButtonFor(), how do you group so only one selection can be made?

This one has me stumped, I have a strongly typed view that has this loop to generate radiobuttons: <% foreach (QuestionAnswer qa in Model.QuestionAnswers) { %> <%= Html.RadioButtonFor(model => model.QuestionAnswers[(int)qa.QuestionID - 1].AnswerValue, "Checked" ) %> <%= Html.Encode(qa.OptionValue) %> <% } %> It renders fine...

How should asp.net custom errors work?

I have implemented custom errors in my asp.net mvc application by following this article. What I have noticed is that if I go to http://www.mysite.com/some-non-existent-controller-and-action I get my 404 error page as expected. However, looking at what happens with firebug, I see that I get a 302 Found response for the non-existent page,...

JavaScript url auto-resolution in Asp.Net MVC

I am running Asp.Net MVC 2.0, and I am running into a problem with my JS calls. this is what I have in my : <link href="../../Content/Site.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="../../Scripts/jquery.js"></script> Which all works fine if I am on the root level. But if I jump up to something like:...

Is there a better way of updating via LINQ to SQL when you have the modelItem from mvc.

I get a LINQ object from MVC2 that I want to update to the database. My current code looks like this: public PersonTbl Save(PersonTbl item) { if (item.ID == 0) //new item { _dbContext.PersonTbls.InsertOnSubmit(item); } else { var item2 = _dbContext.PersonTbls.S...

How to submit an ASP.NET MVC form using javascript and still validate on client side?

I have an ASP.NET MVC 2 form that is working perfectly, doing client side validation (using Data Annotations). Whenever users click on the submit button, client side validation kicks in before the form is actually posted back to the server. This is the actual code, really basic stuff: <% Html.EnableClientValidation(); %> <% using (Html...

NLog Database Target Not Finding Table

I am using NLog 1.0 and have the following configuration file: <?xml version="1.0"?> <nlog autoReload="true" throwExceptions="true"> <targets> <!--<target name="console" xsi:type="ColoredConsole" layout="${date:format=HH\:mm\:ss}|${level}|${stacktrace}|${message}" /> <target name="file" xsi:type="File" fileName="${base...

Is it possible to load an Excel file to memory?

I have a website where businesses can load items for sale. Then end users can search for that item, and find all the stores that carry it. Most stores sell more than 100 things, and while I do have a form for inserting a single item, it's tremendously stupid to have only this for businesses to offer things. My idea is to have an option...

Is MVC .net right for my project type?

After countless hours researching (creating a few demo projects, viewing webinars etc..) I feel like MVC .net works great for 90% of the web application types out there, but not for mine. Basically I have a dashboard application where I'm displaying large amounts of information in many different graphs / charts (all on the same screen)...

Why am I getting "The directive 'control' is unknown" error in ASP.NET MVC?

Hey SO, I'm working on an editor page for a project in ASP.NET MVC. I would like to use a control for both the create page and the edit page so I don't have to duplicate code. I've set up an EditorTemplates folder inside /Views/Shared to hold my templates. And I've placed a .ascx file in there called ArticlePresentation.ascx. ArticlePr...

How do you suggest I approach this unique problem?

I have a website where I allow businesses to register what products they sell individually. Then a consumer can online and search for a product and receive a list of all the shops where it's currently selling. Although they can upload one product at a time, I want to allow businesses to mass upload things they offer. I was thinking of ...

What enterprise sites are using ASP.NET MVC / MVC 2? Need justification for management for moving to MVC.

I've tried a few google searches and stack over flow searches, but this is proving hard to find than I thought. I need to provide justification to management for our shop to move to ASP.NET MVC 2. The biggest help would be any enterprise level sites or major web development shops that are using ASP.NET MVC 1/2. Does anyone have a list ...

Stop exception from being thrown for non-existant controller

Ok, so I am stumped on this issue. I have seen a lot of things that are supposed to resolve this issue, but I am not getting a resolution that can fulfill my requirements. I am using ELMAH to log exceptions and am getting this exception when either a URL with invalid controller or proper controller and invalid action. System.Web.HttpEx...

How to Overload ActionResult in Asp.Net MVC2

Hi I have problem with ActionResult Method overloading in MVC2 I have 3 methods public ActionResult MyMethod() { var data = ........ //some unfiltered data from db return view(data); } public ActionResult MyMethod(string name) { var data = ....... Where xxx.StartsWith(name) //some filtered data by name ...

Using ListBoxFor in ASP.NET MVC 2

Hi, I am trying to update the Roles a specific group has in my application. The Group model I use in my view has an additional AllRoles IEnumerable attached to it, so that in my view I can do something like this: <%: Html.ListBoxFor( model => model.aspnet_Roles, new MultiSelectList( Model.AllRoles, "RoleId", "RoleName" ), new { @class =...

How do you use Autofac to inject setters into your action filters in ASP.NET MVC2?

I thought this would do the trick in my Global.asax Application_Start, but it doesn't work: var builder = new ContainerBuilder(); builder.RegisterType<ExtensibleActionInvoker>().As<IActionInvoker>(); builder.RegisterControllers(Assembly.GetExecutingAssembly()).InjectActionInvoker(); What am I missing? ...

Where should I save an image in my project?

I'm creating a website using MVC2. Where do I save the image? ...