asp.net-mvc

How do you close an ASP.NET MVC page from the controller?

I have an ASP.NET MVC app that opens a "Request" view in a new browser window. When the user submits the form, I'd like the window to close. What should my RequestController code look like to close the window after saving the request information? I'm not sure what the controller action should be returning. ...

Generic Type Model Binding and the BindAttribute

I'm running into an issue with the bind attribute in asp.net mvc. I have a custom ViewModel that looks like this: public interface IUserView<TUser> where TUser : User { TUser User { get; set; } string Email { get; set; } string ConfirmEmail { get; set; } string Password { get; set; } string ConfirmPassword { get; se...

$(document).ready in ascx page after ajax callback

I'm having a little problem with this setup here I have a list of .ascx files and they all do different tasks in terms of calculations to the controller itself. So on my .aspx page I click on an Ajax.ActionLink() and this will render that specific .ascx file based on the item I clicked. Within that .ascx are 1-3 events that will fire 2 o...

Returning data from controllers to views in asp.net mvc

Is it possible to return a complex type from a controller to a view in asp.net mvc? All the examples I have looked at so far demonstrate passing simple intrinsic types like int, string.... ...

Jquery Autocomplete Chained Requests

Hi, I have a page with two input fields City and Venue. I have the autocomplete plugin from Devbridge working great for the city field. I now want to get it working on the venue field. The javascript I have so far is: <script type="text/javascript"> $(document).ready(function() { $('#Event_City').autocomplete({ ...

How to cancel an ASP.NET MVC action

This should be simple, but the answer is eluding me. If I've got a Save action in my controller, and the save fails, how do I cancel the action without disturbing what the user entered? For example, Index is strongly-typed of "MyTable": Function Index() As ActionResult ViewData("message") = "Hello" Return View(New MyTable) End F...

Why did Microsoft choose MVC for ASP.NET?

In addition to being a 30 year pattern, MVC was never meant for current applications. MVP was its successor and designed to handle event based apps coming out in the 90s. Passive View and Supervising Controller seem to have risen to the top. For those two, it almost isn't necessary to talk about MVC/MVP. Specifically, is the controll...

linq datacontext GetModifiedMembers in Attach scenario

I am trying to implement Optimistic Locking in an asp.net MVC application, as well as provide audit trailing. The audit framework relies on being able to call DataContext.GetModifiedMembers during SubmitChanges, which makes good sense, i guess. The optimistic locking uses ROWVERSION timestamps, serialized to base64 and put in a hidden ...

From controller enforce required param on an MVC strongly typed view?

I have a controller with that I want to pass off some data to a view. The view is strongly typed like: System.Web.Mvc.ViewPage<SomeObject> Now when I call the following in the controller: return View("SomeAction", someObject); I want it to enforce that I need to pass in 'someObject'. Eg. I want the following to fail and not compi...

Help Linq to Sql

Why am I getting a exception when ApplyPropertyChanges??? The code is almost the same when I'm editing a user table but is not working with my news table. The create, delete and details are all working fine but when I try to edit a news I'm getting the exception below: The ObjectStateManager does not contain a ObjectStateEntry 'MagixC...

JQuery calling Action on Controller (But not redirecting after)

I have a JQuery confirmation popup, with Yes, No buttons. The Yes button calls this function: function doStuff() { $('#confirmPopup').dialog("close"); var someKey = $("#someKey")[0].value; $.post("/MYController/MyAction", { someKey : someKey }, function(responseText, textStatus, XMLHttpR...

.net mvc 1.0 Html.TextBox

I have following code which only works for first time page is hit. <%= Html.TextBox("Amount",Model.Amount)%> In above line, debugger shows property calls to get Model.Amount each time the view is being generated. But updated value of Amount is not reflected in generated HTML. Help ...

Removing extra whitespace from generated HTML in MVC

I have an MVC application view that is generating quite a large HTML table of values (>20MB). I am compressing the view in the controller using a compression filter internal class CompressFilter : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) { HttpRequestBase ...

ASP.NET MVC Html.TextBox @class = "MyClass" not working

I am using the Html.TextBox helper method to generate a textbox against my model but when i pass in an anonymous htmlAttributes class with @class defined like below, the class is never assigned. Am I doing something wrong? I have assigned a readonly attribute the same way and it worked. <%= Html.TextBox("LastName", Model.LastName, new...

Mixing ASP.NET Webforms and ASP.NET MVC

I am having trouble with forms authentication. The root web.config is setup to deny access to all non authenticated users with a structure like: Controllers Folder - Webforms Folder1 - Webforms Model Public Folder - Webforms with web.config to allow public access Views web.config with deny I need to have the home controller public as...

ASP.NET MVC vs. Webforms vs. HTTP Handlers (.ashx) - which is the most lightweight?

I plan on building a simple, yet high usage webapp and need to settle on an architecture. basic server side logic / dynamic db driven content about half a dozen to a dozen pages serving up all said content no need for URL rewriting, pretty simple page flow/routing The objective is to publish this app to use the least amount of band...

Disable all controls (textbox, checkbox, button etc) in a View (ASP.NET MVC)

While rendering the view page, based on some condition in the controller action I want to disable all the controls (textbox, checkbox, button etc) present in the form in a MVC view page. Is there any way to do that? Please help. ...

ASP.NET MVC ,What is the Models Folder for?

Another repository of App_Code? Inside the NerdDinner sample, it contains some share interface, function , class with property etc. Not much different with App_Code. ...

How to get asp.net Session value in jquery method?

I want to access a Session value in jquery method in the ASP.NET MVC view page. See the below code, $('input[type=text],select,input[type=checkbox],input[type=radio]').attr('disabled', '<%= Session["CoBrowse"].ToString() %>'); Please advice how can I get the Session value in jquery. ...

Building dynamic form parts using jQuery

(Hope this doesn't get duplicated; second attempt at submitting this question) I'm working on a form in which I'd like to give the user the ability to add an undetermined number of Contacts (Name and Phone Number). I only want to show one row of these form fields to start with, and allow the user to click an element which will add dupl...