asp.net-mvc-2

How to scroll to selected item in a select box

In my application when I person selects an item at the bottom of the select box the area is reloaded with another select box. My problem is when the select box is loaded it scrolls to the top instead of scrolling to the selected item observe here http://www.jaunna.com/question/Add UserID: top Pass: t ...

How to set model properties during the Model Binding process?

Many of my model object inherit from a class called AuditedEntity that tracks the changes to the object. I would like to have my model objects that inherit from AuditedEntity automatically have the appropriate fields populated when constructed during the model binding process. I have been looking into sub-classing the default model bin...

Update dropdown values

In the ViewModel: SelectSafetyContacts = new SelectList(subcontractRepository.GetContacts(Subcontract.company_id), "contact_id", "contact_name", Subcontract.safety_contact); In the Repository: public IQueryable<contact> GetContacts(Guid id) { return db.companies .Where(c => c.active_status == true) ...

How can we pass class instances to view ?

Hello Everybody I just wonder that can we pass any type of class instances to view which is not exist in our Model repository.for example i just want to show property values of any class instance which exist in .net framework such as List, ListArray and others. Edit: Question is edited cause misunderstanding possibility. ...

Why does my ActionFilterAttribute redirect after the action code is run?

I'm trying to use a ActionFilterAttribute to redirect users that are not logged in. Although my redirect is working it redirects but it calls all of my ActionResult code first. Any ideas as to why it doesn't honour the true flag and end the response? HttpContext.Current.Response.Redirect("~/Logon",true); Here is my ActionResult: [Re...

Change or switch request data

I'd like to create filter which will switch request data. More precisely i'd like to change type of request inside filter (it have to be POST), add some values into post's Data, add return url, and redirect it to Controller's action which accepts only POST... and then in this action i'd like to return to first URL. I've found something ...

RedirectToAction outside of Areas

Hey everyone, I've recently updated our MVC 2 project at work to use Areas however I'm having a little problem with the RedirectToAction method. We still have some of our controllers etc outside of our Areas. These controllers include the Home controller etc. How do I do a RedirectToAction from inside an Area to a controller outside o...

Using Json and jQuery to populate DropDown from a list of custom classes in Asp.Net MVC 2

I'm trying to populate a DropDown from a Json result using jQuery. I have the following class: class MyOption { int Id { get; set; } string Name { get; set; } } I'm not sure how to get a list of these into my Json result. At the moment I have the following, I'm not sure if it's correct but it compiles and runs: return Json(...

Asp.Net MVC double submit/request breaks SQL connection

Hello all, I am running into a strange problem I don't fully understand. The main symptom is that when I double click a link (that points to a controller action) in my MVC application, my database server connection gets blown, and I get the error : Execution of the command requires an open and available connection. The connection's cur...

ASP.MVC2.0/EF4.0 site deployment/maintenance

Hello, My small team used asp.mvc 2.0/entity framework 4.0(model first approach)/Windows Server 2008r2/Sql Server 2008 r2 stack in out web site project. We've already complete developing process, and come to the web deployment stage. In this stage we are faced with the problem - ok we'll use vs2010 features for initial server/db deploy,...

nhibernate not pulling back the entire object

I have the following method that creates a view model. On my mvc app i called this on http get: "/Product.aspx/Edit/8024" and then on http post "/Product.aspx/Edit/8024" My issue is that when i called it on "post" i don't get the entire product class, ie it's missing generic list ie List<Category> categories Here is the method t...

ASP.NET MVC Authorization with jQuery & AJAX posting in IE

I'm not sure how to post this question without including half of my sites code, but here goes. I have a site with a Subcontract Form, a Company Form, and a Contact Form. From the subcontract form, you can create a new company and/or a new contact via buttons which open jQuery dialogs and post the company or contact information. From t...

Why does a trailing %20 (valid data in this case) kill asp.net mvc routing

Take the following controller action public ActionResult NextBySURNAME(int id, string data) { //code to process the data and edit the id accoringly not written yet return RedirectToAction("Edit", new { id = id }); } if I call it with /Mycontroller/NextBySURNAME/12/Smith%20Simon then it works fine (in this...

Telerik MVC Extensions deployment problem

I am writing a website which uses Telerik MVC Extensions, and am getting an error on my test server when I get no such error on my development PC. The error is ... Web.config(101): error CS0246: The type or namespace name 'Telerik' could not be found (are you missing a using directive or an assembly reference?) Here is the r...

How to make an asp.net mvc application to stay compiled

I have precompiled my application but every 10 - 30 min it unloads then when the page is hit it takes a long time to load. How do I make the application stay compiled forever? ...

ControllerContext.IsChildAction invocation failed with mock behavior Strict. All invocations must have a setup.

I am toying around to learn how to unit test ASP.NET MVC controller actions. Specifically I'm trying to mock the ControllerContext so that I can test an action that accesses HttpContext.Current.User.Identity.Name. I'm using Moq. Things were going pretty well until I turned on MockBehavior.Strict. I knew that this would throw an excep...

How to implement historical versioning?

We are in the early stages of building a large C# MVC2 app (we also employ Sharp architecture and Nhibernate as part of the ecosystem) on SQL 2008 R2, and one of the requirements is that all database row versions are accessible for a given period of history. We have toyed with the idea of a layout similar to: id (PK) recordId versionId...

ASP.net MVC 2 Application Tutorial using Entity Framework with many Tables

I am a newbie to ASP.net & MVC 2, and have understood the basic concepts of how views, routes and controllers are implemented in it. Having great trouble with the MVC 2 "Models" though because I have always avoided ORM's. Please point me to some good ASP.net MVC web application tutorials that use ADO.net Entity Framework with many table...

Whats so great about the new MVC2 areas?

Could some one please explain the advantages and disadvantages of using the new MVC2 Areas feature? I don't understand what is so great about them. If I am adding an admin area to my MVC application why not create a new Admin folder in the main Views and Controllers folder? What does creating an area really get me? I fail to see much ...

ASP.Net MVC Keeping parameter names and action argument names in sync.

I've noticed a pattern that can make refactoring MVC2 apps difficult. When you change the name of an argument for an action you must update the values everywhere that action is used. For example, public ActionResult List(string p) in the view <%= Html.ActionLink("List", "Directory", new { p = "somePath" }, null) %> What if I want t...