asp.net-mvc-2

How to set up Database for ASP.NET MVC Application

I created an data driven ASP.NET MVC Application locally and it works fine. Within my App_Data Folder of my project i see two databases: ASPNETDB.mdf and myProjectDatabase.mdf. I uploaded my project files an the webserver, so that I can actually open the website. But I couldn't figure out how to connect my Database that I created locall...

Post collection of C# objects using WebClient

I am trying to post to an ASP.NET MVC action from another Action (separate sites) and I need to post a collection of objects. I'm unable to find how to serialize this collection of objects so I can get them as a standard NameValueCollection. Example: var test1 = new TestObject { FirstName = "John", LastName="Smith", IDNum=...

ASP.NET MVC 2 Point Return Links to Appropriate View

The default scaffolded views generated by ASP.NET MVC 2 contain links such as: <%: Html.ActionLink("Back to List", "Index") %> <%: Html.ActionLink("Create New", "Create") %> These links are perfect if I came to this page from that same root. But for example, if I have Orders and Persons and I navigate to /Orders/Edit/17 via /Persons/O...

Maintaining state in a MVC2 Controller...

Hi... I want to maintain model state between method calls on the controller. Is that possible? A controller is created at the call of some of its methods and destroyed when the called method finishes its execution? If not... how can I maintain the state between method calls? If that is possible... how has it to be written? thanks ...

Returning response from a view that contains input type file - Microsoft JScript runtime error: Object expected

Hi guys, I have a simple view that has 2 textboxes and 1 file input. <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<iLoyalty.BackOfficePortal.Models.SegmentModel>" %> <% using (Html.BeginForm("SaveSegment", "Segment", FormMethod.Post, new { id = "SegmentForm", enctype = "multipart/form-data" })) { %> <div class="StCon...

ASP.NET MVC debugging

I have trouble debugging ASP.NET MVC (1 & 2) in VS2008. Most often stepinto and stepover is just like hitting run. This also happens even if there is a breakpoint in the code on the next line. I've experienced this problem all along using MVC and others working in my team experience it as well. Does anyone else have this problem? Is th...

Compile views with enabling MvcBuildViews into MVC 2 Portable Area

I have a big .net mvc 2 project where we are using MvcContrib Portable Area. There is a main web site which load many modules (PA modules). The main application contains Site.Mater into its ~\Views\Shared folder. each module also has own Site.Master which inherit from that main one. At the moment we are using something like: <%@ Maste...

How to get the id value in controller/action/id

Hi, I have an edit application view, and it can be found at the following URL: http://localhost:17262/Application/EditApplication/1 1 equals the application ID. Also on the page I have a link that goes to another view to add an assistant for the application. I want to pass it the application ID so that the new assistant can be "link...

Data from UI to Controller in ASP.NET MVC

Hi, Could you you tell me the best way to get data from UI to send them to the controller. What do you think a bout the code below ? Is there an another solution without all this javascript/jquery/ajax code ? Thanks, function CustomerAddSave() { $('#btSave').bind('click', function (event) { $.ajax({ type: "POST...

Running code coverage with Gallio in VS 2010 x64 machine

The target framework is .NET 4.0. My solution is a ASP.NET MVC2 project. I'm using the latest Gallio/mbunit build 3.2.603. When trying to run code coverage on some mbunit tests, I get no results : Empty results generated: none of the instrumented binary was used. Look at test run details for any instrumentation problems. The tested mbun...

Refresh several partial view ...

Hello, Is there a way to refresh several partial view from the controller ? (return View()) Thanks, Update1: Example, the content pârt of my screen is divided in 2 parts, on the left a customer list on the right the details customer, the details of the customers selected in the list of the left. If I create an new customer, when I sav...

MVC OutputCache issue

I am trying to cache the output of a controller action in MVC2 like this: [OutputCache(Duration = 600, VaryByParam = "id", Location=System.Web.UI.OutputCacheLocation.Server)] public FileContentResult GetImage(int id) { } When the user uploads a new image for their icon I invalidate the cache using the following line: HttpResp...

Empty model when submitting asp.net mvc 2 form.

Hi! I gotta the following code in controller and view. The problem is that the model(Photo is an Entity Framework entity) is empty(all fields are nulled). Why? // GET: /Admin/Photo/Create public ActionResult Create() { return View(); } // // POST: /Admin/Photo/Create [HttpPost] public ActionResult...

JQueryUI DatePicker won't work in my ASP.NET MVC 2 application

I'm just trying to set up an input with datepicker and I'm getting the following error: "Object doesn't support this property or method". I downloaded the JQueryUI without a theme and there is my head section of the master page: <link href="/Content/Site.css" rel="stylesheet" type="text/css" /> <script src="/Scripts/jquery-1.4.1.min.js...

How do I embed a flash object in my MVC2 Application Home?

I need to put a Flash Object in my website developed on MVC2 .NET, however the third party who made it just gave me an html with this code.HTML errors apart I don't know how to put it on ASP.NET. Can you help me? <table width="608" border="0" cellpadding="0" cellspacing="0" bgcolor="#F4F4F4"> <tr> <td height="4...

ASP.NET MVC app can't find Views since I moved my app to a new directory

I copied my app and put it somewhere else. Then I changed IIS to look at the new place and ran it. Debugging it - it runs through my Controllers in the new location fine. But when it nips off to get the view it goes to the old location of my app?!? ...

In asp.net mvc 2 . Add new relation record in the Create View.

Here is my database design. Contact ContactID ContactName EmailAddress EmailID ContactID EmailText In the create View, I have ContactName Field and a button Add Email Address. When I Click on the Add Email Address, there is a popup who perform an ajax request to get the Address Fields. My problem is that I need to create the Contac...

How to Get Model Data from Partial View?

I am creating a site in which I utilize partial views to display various bits of data about a single Model. Here is a bit of the HTML. (Note, all of these are contained within a single form and the Index page that these partials are rendered in is strongly typed to the main model. The main model contains various lists of data.) <div id=...

MVC 2, Format Model display into a textbox

I have an easy one for you guys. In my view I have a textbox, like so: <%= Html.TextBoxFor(x => x.Price, new { @class = "text tiny" })%> Price is a decimal. When the form loads up. the textbox displays "0". I would like it to display "0.00". I tried <%= Html.TextBoxFor(x => String.Format("{0:0.00}", x.Price), new { @class = "text ...

MVC 2 and EF4 Self-tracking entities models have bad state on post back

I've got standard Create() Edit() and Delete() methods on my controllers, and I am using the EF4 Self-tracking entities. When the edit is posted back, the model.ChangeTracker.ChangeTracking = false, and model.ChangeTracker.State = ObjectState.Added, even though I made sure those are set when retrieving the record initially. Are the sel...