asp.net-mvc

LINQ to Entites: sub-objects disappearing

I'm trying to understand why, sometimes, my sub-objects disappear. In my List view, I have the standard <% foreach (var item in Model) and when I inspect the item and the model, I can see that item.Map has a couple of elements. In fact, in my List view I can do: <% foreach (var map in item.Map) <% Html.RenderPartial("MapView", ...

Redirecting to Previous action after form submission in asp.net mvc

I have a form on all my pages that allows the user to select their language. After this action completes I change the current language for that user then I need to make sure I redirect to the same action they were on previously. I am not sure what the best approach is to do this in asp.net mvc. One approach is that on every page I sav...

ASP.Net MVC passing database string to checkbox value

Hello all, this is closely related to a question I posted yesterday regarding checkboxes. Here is my setup: -I have a database directory, with a list of names, among other fields, as my model. -I have a search page where users can search this directory and select a name. -I have a form page that displays the name with a checkbox ne...

Visual Studio 2010 with ASP.NET MVC1.0

Is it possible to use Visual Studio 2010 to write code for shared hosting that is designed for .NET 3.5 and ASP.NET MVC 1.0? I've been trying for a while to get a project to run that uses only 1.0 features, and it just will not translate over very well. ...

asp.net mvc: is this a bug or a feature when using partial views on objects that have the same field names?

My classes are a DataModel, which uses ID as its PK, and a Map, which also has ID as a PK. Map has a FK to DataModel (DataModelID). I have a partial view that I use from my DataModel list view as follows: <% foreach (var map in Model.Map) { %> <% Html.RenderPartial("MapEdit", map); %> <% } %> My MapEdit partial view looks lik...

MVC $.getJSON works first time on master page, then stops calling url on subsequent loads

I have an MVC masterpage set up which loads a dynamic menu using AJAX Templates and JSON - the JSON is returned with the following call: var tabList = []; //this holds the json data on the callback var getTabs = function () { $.getJSON('Home/TabList', null, function (json) { Sys.Observer.clear(tabList); Sys.Observe...

IIS 7.5 MVC 2 problem with 401.3 error.

I have a mixed WebForms/MVC application I'm trying to deploy to our staging environment, which is a fresh install of Server 2008 R2, with IIS 7.5. This application works fine while developing on anyone's local machine (via visual studio's web server), however when when it's hosted on the staging server we get the following error: HT...

controller viewdata object into jquery

I am new to mvc and jquery In my controller I have ViewData["a"]="true"; I want to access the viewdata object in jquery <% if(ViewData["a"] == "true")%> { $('#div1').show(); } The above jquery doesn't work for me Can someone please shed light on this. Thanks in advance ...

How to access HttpContext outside of controllers in ASP.NET MVC?

Specifically, Session variables. I have an .ashx in my ASP.NET MVC project that is pulling some image data to display to a user, and I need to be able to access an object that I've stored in the session. From controllers I can pull the object fine, but in my ashx page, the context.Session is null. Any thoughts? Thanks! Here is an exampl...

How to populate strongly typed viewdata from a base controller?

All my controllers are based off of a BaseController, to share properties between them and override OnActionExecuting to set some values based on the route. I'm creating a BaseViewData class to do the same for all my view data. At the moment I'm populating the view data like so (C#): var viewData = new BaseViewData { Name = "someN...

Custom Binding in ASP.NET MVC with naming-conventions

Hey all I've got a View where I use a naming-convention on my text-fields, to indicate what should be done with the content once it is posted back to my controller. The format is similar to: <input type="text" name="RegistrationLine#ID" /> for updates <input type="text" name="CreateRegistrationLine#LineNumber" /> for create Now sinc...

Json isn't returning a result that is accessible as an array...

I'm having troubles reading a Json result back from a controller method... I have this method in my controller: [AcceptVerbs(HttpVerbs.Post)] public JsonResult GetCurrent() { IList<string> profile = new List<string>(); profile.Add("-1"); profile.Add("Test"); profile.Add(""); return t...

ASP.NET MVC Form Validation using JavaScript

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage>" %> Index <script src="/Scripts/jquery-1.3.2.min.js" type="text/javascript"></script> <script type="text/javascript" src="/Scripts/jquery.validate.js"></script> <script type="text/javascript"> input[type=text] ...

Performance wise Is MVC better than Web Forms in ASP.NET

We are going to develop a website in ASP.NET. So is it better to use MVC or web forms. ...

Error Getting Jquery Blur to Work on Element

Hello, I am developing a form that allows users to enter their credit card information to complete a transaction. I validate on the server, but want to provide smooth client validation as well. I am using ASP.NET MVC with JQuery. What I am doing is using the JQuery blur function to execute the javascript whenever someone moves focus awa...

How to do the checkboxfunctionality in MVc Asp.net using C# Application?

Hello All, I am having a edit client form in my application which is having an acheckbox labeled isActive and in the database the datatype of the isActive field is integer.The field isActive is not mandatory , the user can select it or else it cannot it is on his own wish. I am receiving the below error If I am not selecting the checkbo...

ASP.net web form - post data to a controller in an MVC site

This may be a stupid question, but anyway... I have an MVC site and a legacy ASP.net web forms site. I have a controller action on my MVC site that I would like to (programatically) POST to from my web forms site. I can find lots of information describing RESTful services etc., but I can't seem to find a resource that explains how to d...

Looping checkboxes and checked if exists

Hello I'm trying to generate a list of checkboxes, and make them checked if they exists for a product. Kinda like Products <-> ProductsCategories <-> Categories Kinda like: <% foreach(var x in Model.Categories) { %> <%= Html.CheckBox("CategoryID", checked if exists in Model.Product.Categories)%> <% } %> How is that ...

Why does RouteLink generate friendly URL while ActionLink does not?

Hi there. I have a question regarding RouteLink vs. ActionLink. Consider the following route routes.MapRoute("Routename1", "{someEnum}/SpecificAction/{id}/{stringId}", new { controller = "MyController", id = (int?)null, stringId= (string)null, action = "SpecificAction" }, new { someEnum= "(EnumVal1|EnumVal2)" } ); The we...

Why does my http response body suddenly contain a load of gibberish?

I'm trying to refactor an existing asp.net-mvc web application and introduce mvc-turbine. The application works as is, but I want to make it more pluggable and maintainable so future maintenance will be easier. I figured I'd try to keep the refactoring steps as small as possible, so I referenced MvcTurbine, MvcTurbine.Unity and MvcTurbi...