asp.net-mvc-2

ASP.NET MVC 2: Where to put custom JS files?

Hi there, what is the recommended place to put .js files - not really talking about jquery etc.... but my own custom js files.. The scripts directory seems to contain ajax, jquery etc... So is this the correct place? OR would a better place be COntent? I also was doing a search and saw some arguments for placing the JS files in the V...

StructureMap injected IContainer - where does it come from?

I have an ASP.Net MVC application and I am using StructureMap within MVC to glue the whole application together. There are some model classes that have heavyweight dependencies that are not used in all public methods, so I pass in an IContainer to the model constructor and use that to create the heavyweight dependencies on demand. My qu...

HtmlHelper not recognized in runtime

Hi, I am developing a Web app that is based on ASP.NET 3.5, and i added some page from ASP.NET MVC, everything is ok, until i use the "HTML" helper class, then the page is not being able be render, because this is not recognized. For Example : Html.BeginForm() => this is not recognize as a method But if i used "System.Web.Mvc.Html.Form...

Ajax.BeginForm with multiple buttons

can i have more than one AjaxOptions in Ajax.BeginForm targetting different controls? ...

how to attach value to listbox

I'm having an issue where if they type in a new Person, then select "M" or "F" from the dropdown, in the listbox, I want both to show resulting to "John Doe M" with the example code: <div class="editor-field"> <%= Html.ListBox("personList")%> </div> <%= Html.TextBox("newPerson")%>&nbsp; <select name="personInfo"> <...

JQuery UI button triggering "potentially dangerous Request.Form value" error in IE

I have begin testing my application with IE and have found that buttons that are styled using JQuery UI button are posting their entire content to the server. This means that they post a span with the text inside it. This triggers a "A potentially dangerous Request.Form value was detected from the client" error in ASP.Net. This does not ...

MVC ActionResult to use when returning html content

I have a some html fragment in memory that I need to render using RenderAction. For instance my action method looks something like this: var html = "some html code How do I make it render this html by using RenderAction, I don't want to create a view file because this is dynamic html. And I can't use any of the file results because thi...

asp.net mvc how it decides which view to load

I am attempting to construct an asp.net mvc app which will use the urls like: /Controller/[Number]/Action/Id I have got it to always call my controller and pass it the Number and the Id fine... However I now want to return a different view depending on the Number I could have options like: if([Number] == 1) { return View("ViewName...

Why is System.Drawing and System.EnterpriseServices in default asp.net mvc 2

Can anyone tell me why is System.Drawing and System.EnterpriseServices include in the default asp.net mvc 2 project? ...

Can't make jquery validation with ajax.beginForm in PartialView work

I'm loading partial views which are ajax Forms. They look like this <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<WebGRC.Web.Controllers.Models.Administration.UserAdminModel>" %> <%@ Import Namespace="WebGRC.Web.Controllers.Models.User" %> <h2><%=Html.Encode(ViewData["HeaderText"])%></h2> <% Html.EnableClientValid...

How to initialize a javascript variable using Json String in Asp.net MVC?

I have the following Action method. public ActionResult Action() { var model = new SampleViewModel(); model.JsonString = ReadJsonStringFromSomewhere(); return ViewResult(model); } In my view I have the following method to initialize a javascript variable. <script type="text/javascript"> var jsObject = eval("(" + <%= Mod...

ASP.NET MVC 2: Any way to pass two Objects to a Template?

A "Lookup" in this example is an IList<string> of state abbreviations. Generally, your Domain Model POCOs won't include these options. ViewModels usually take this responsibility referencing both the original Domain Model as well as the Lookup object, but what happens when the Domain Models are nested and you are using MVC templates (w...

Routing problem with - in varaible

I have a rute in my asp.net mvc 2 site that looks like this routes.MapRoute( "media_display", "Media/{mediaId}-{mediaName}", new { controller = "Media", action = "Display" }, new { mediaId = @"\d+" } ); Where mediaId is the id, and mediaName is the title of th...

ASP.NET MVC helper for accessing Gravatar images

Whilst the Gravatar service's API (well, it's really just a URL) is pretty straightforward, is there a simple helper method out there that does a good job of reflecting all the options available for Gravatar? Image size Default image (when user hasn't specified one) Rating (G/PG/R/X) Ideally this would be an HtmlHelper extension meth...

is a background worker in a controller async?

Inside an asp.net mvc 2 controller, I have the following code: using (BackgroundWorker worker = new BackgroundWorker()) { worker.DoWork += new DoWorkEventHandler(blah); worker.RunWorkerAsync(var); } My question is: is this code asyn...

MVC2 Quote handling / escaping within a style attribute

I have no idea how to handle this code within a style attribute. How do I correctly code this markup or properly escape it? I could use a string.format and emit the entire div but that seems like an awkward solution. (I figured all those slant brackets would pose an issue in this posting so I am including an image.) ...

ASP.NET Connection Reset on Upload

Hi all, I'm running into a problem with my app (ASP.NET MVC 2) where I can't upload files (images in my case). I've changed the web.config to accept up to 20MB, and I'm trying to upload a file that's only 3MB. The app itself has two ways to upload. The initial upload which starts a Gallery and then an additional upload to append to a G...

ASP.Net MVC2 - IIS7.5 doesn't find view file for home page

We have a mid-sized asp.net project that we just promoted from our dev server (Windows 2003) to an external test server (Windows 2008 R2). On the test server, IIS is not finding our home page, which is located in the views/home folder (404 error). As far as we can tell, the settings are the same on both servers. I've confirmed HTTP ...

controller used to save data, have it return view() instantly and run code in the background

I have a controller whose main function is to save data. The ajax call that saves this data needs to be executed quickly. What I want to do is get the POST in the controller and spin off a background thread that will do the actual work to save the data; this would allow me to do return view() instantly. So essentially the only lag it w...

CMS: How to combine static pages with several stray different Controllers/Views in ASP.NET MVC 2

I am working on a CMS managing my website's pages' static content. There is a PageController (the default route www.mysite.com/pages/2/page-title is used) and the corresponding Views displaying the pages' static content that can be managed using WYSIWYG editors in the administration interface. I need to be able to specify that any arbit...