asp.net-mvc

JqGrid not loading data from asp.net mvc action

Hi, I run into this problem few hours ago, and I can't get around it. I'm trying to implement JqGrid into my ASP.NET MVC application. I was using examples from Phil Haack's blog post. I imported js and css: <link href="/Content/jquery-ui-1.8.5.custom.css" rel="stylesheet" type="text/css" /> <link href="/Content/ui.jgrid.css"...

How do I close a window using a button (window.close() doesnt work)?

I open a new window and would like to give the user the option of closing the window using a button. I thought window.close() would work, but nothing happens. Below is a copy of my code. <script type="text/javascript" language="javascript"> function CloseWindow() { //window.open('', '_self', ''); window.close(); } </script> .....

Where in my application belong the DTO's that are used to export and import in structured format?

Our users need to be able to export data in CSV format, edit some of the records, and upload the data again. The data does not map to entities, you could say that the object graph is flattened to fit in the Excel-based workflow. Right now this happens in the controllers because I thought these DTO classes were view models. It smells but...

Help Rendering ASP.NET MVC View from a Console App

I have created an ASP.NET MVC View. On my MVC WebApp, it works great. I would like to be able to (from a console app) render the View out as an HTML Email. I'm wondering what the best way to do this is going to be, the part I'm struggling with is Rendering the View. Is there any way to do this from a console application? The webapp ...

ASP.NET MVC 3 beta: TryUpdateModel throws NullreferenceException in unit test

Hi, Since I updated to ASP.NET MVC 3 Beta 1, I get a NullReferenceException whenever I call TryUpdateModel() during a unit test session. The stack trace looks like this: Execute System.NullReferenceException: Object reference not set to an instance of an object. at System.Web.Mvc.JsonValueProviderFactory.GetValueProvider(Con...

Multiple views or single view using flag on ViewModel

I have a situation where a controller action should result in the information about a given object being displayed differently depending on the user's permission on the object. Currently the controller action code returns one of two views accordingly: Info.ascx or Info_ViewOnly.ascx. As the differences between these two views are very ...

mvc 2 upload with vb.net

I didn't find any answer on web with vb.net (I find millions of samples with c#) I translated a sample controller to vb.net but doesn't upload My ResimController.vb <AcceptVerbs(HttpVerbs.Post)> Public Function Anasayfa(ByVal forms As FormCollection) As ActionResult Dim errors As Boolean = False If String.IsNullOrEmpty(forms(...

MVC View Model Get Child Object

I have a main Contact and ContactViewModel . How do I get contact model and update it to the database ? [HttpPost] public ActionResult EditContact(ContactFormViewModel contactView) { } I was doing like this before I needed ViewModel [HttpPost] public ActionResult EditContact(int id, FormCollection collection) { ...

ASP.NET MVC Complex Model Validation

I have a complex Model public class ComplexModel { public UserModel userModel; public ExtraInfoModel extraModel; } where UserModel may have required fields as in: public class UserModel { [Required] public string email; } how do I validate ComplexModel to make sure that the data annotations on its member mode...

ASP.NET MVC Int Array parameter with empty array defaults to {0}

I have a controller action like: Public ActionResult MyAction(int[] stuff){} I make a JSON request like: $.getJSON(url, { stuff: [] }) When it gets to C# it looks like an array with one element in it, which is zero (i.e. like if I did int[] stuff = {0};). Is this new with MVC 2 or .NET 4? It seems to have changed recently, but I ...

ASP.NET MVC: How to handle model data that must go to every view?

So if there is some global state that every view of an MVC app will need to render ... for example: IsUserLoggedOn and UserName ... whats the appropriate way of getting that information to every view? I understand that that part of the view should be in the master page or in a partial view thats added to the other views. But whats a goo...

ASP.NET MVC displaying user name from a Profile

The following is the LogOn user control from a standard default ASP.NET MVC project created by Visual Studio (LogOnUserControl.ascx): <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <% if (Request.IsAuthenticated) { %> Welcome <b><%: Page.User.Identity.Name %></b>! [ <%: Html.ActionLink("Log Off", "LogOff", "Accou...

Can you map the results of a manual SQL query to objects in Entity Framework?

In LINQ, you can write a manual SQL query, take the results from it and have LINQ "map" those into the appropriate properties of your Model classes (or at least, I'm pretty sure I read you can do that). Is it possible to do something like that in Entity Framework? I have an web app that's using EF, and it's CPU usage is ridiculously hi...

ASP.NET MVC DropDownList: Getting the Selected Text (rather than the Value)

Once upon a time, I had a DropDownList with Options built using this code: <%= Html.DropDownList("SomeName", someSelectList)%> which produced HTML like this: <select id="SomeName" name="SomeName"> <option>ABC</option> <option>DEF</option> <option>GHI</option> <option>JKL</option> </select> Form Submission would always return one of...

MVC application gives an error with routing

I installed a MVC app on one of the machines and it works great. With the same code base, when I install it on a different machine, I get the following error: A route named "myroute" is already in the route collection. Route names must be unique This makes me want to say something is not correctly installed on the the second machine....

ASP MVC - ConfigurationManager Cannot find Appsettings

Hey all.. I am using MS Test to test one of my controller's actions. This method uses the ConfigurationManger to read appSettigns from the web.config. For some reason ConfigurationMangager is not able to find the appsettings. In NUNIT I would just make sure to add a copy of the webconfig file to the test project so that it is available ...

ASP.NET MVC2 Application's submit button returns URL with an appended "Form"

OK, I'm sorry if the tile of the question was unclear, and if you understand what I mean, please don't hesitate to help me think of a better one. Anyway, I have a <input type="submit"> element for my form, and I want it to return the same URL as the URL of the page the element is on. Currently, if I click the button, it takes me from /...

Installing Subtext Blogging Software with SQLCompact 4.0

Does anyone know how to install the SubText blogging software via the MS Web Platform installer, WebMatrix or manually so that it can use a SQLCompact 4.0 database? It says it's possible, but it's really not straightforward or at least does not appear to be straightforward. ...

ASP.NET MVC Application not calculating, n00b question

OK, I have a problem where my calculation never takes place, like it is supposed to. i'm trying to make a computation which solves for the roots of a quadratic equation using the quadratic formula, based on the values of a, b and c entered in a primitive form. Now, let me supply the code for my Model, view and Controller for this appli...

PartialView updating ModelData?

Hi all, am new to MVC but have a Q about PartialViews. I have two PartialViews accessing Model Data from the ParentView (Model Data passed through via the ParentView's Controller). The first PartialView is used to update (add/delete values) Model Data to the database. The second PartialView generates a document based on the ParentsView M...