asp.net-mvc-2

Injecting changes to model data

I have certain entities that have audit trail elements like LastUpdated and LastUpdatedBy. I am looking to determine the most appropriate way to effect an update of these fields to the current date and time and current user when a model is changed. The simplest implementation would be to affect this change in my controller before I upda...

MVC LINQ Query question

In my public ActionResult Active() { var list = _entity.CALL_UP.Where(s => s.STATE == ICallUpsState.FULLY_SIGNED) .Where(f => f.START_DATE <= DateTime.Today && f.END_DATE >= DateTime.Today) .ToList(); return View(list); } This r...

Hierarchical menu in view based on parent child class

Hey There I have a ViewModel: public class Page { public int Id { get; set; } public Page Parent { get; set; } public string Name { get; set; } public string Title { get; set; } } I am passing that model to a view, and i need to create a hierarchical menu based on the model: <ul> <li>Page <ul> ...

Creating a Non-Blocking Process in an MVC 2 Application

I'm faced with setting up a system which will allow users to: Hit a button to initialize a "download & archive" command, which reads file lists via XML, pulls files over HTTP to a local directory, archives them, and stores them away for download. Get a progress bar/indicator telling them their "request is being processed" immediately a...

Index ActionResult returns 404

Hi Guys, Please find below my ActionResult Index: public ActionResult Index(string SectionText) { var products = from p in db.Products where p.CategoryID == SectionText //orderby gs.SortBy select p; return View(products.ToList()); } This is throwing the error below: -...

Is there any big perfomance difference between RenderPartial and Partial?

Also RenderAction and Action. RenderXXX akaik write directly to response stream and XXX use additional string buffer. I don't really want doing benchmark my myself, so maybe someone already do it. ...

Is there a correct way of using the HtmlHelper within a JavaScript function?

I'm writing a jQuery grid plugin and I've designed it so it works independently from the language being used. The following is the basics of how my plugin is assigned: $("#grid").grid({ enablePager: true, dataPath: "Movement/GetGridPage", columns: { Edit: { title: "", cellCallback: editButtonCallBack, width:"16px" }...

Change directory in swfupload jQuery plugin?

I'm trying to use the swfupload plugin to upload files. The thing is, I want the user to be able to switch the directory to upload to. The strange thing is (and maybe this is due to my limited knowledge of jQuery) that it seems like I have the correct directory when checking it with an alert, but still the upload goes to the previously ...

Login system like Stackoverflow's

I want to make a login system just like Stackoverflow's which have at least Facebook, Twitter and Google openid system. Is there a all-in-one library for this purpose which can be used in Asp.Net Mvc 2? ...

How do I reference/access a Strongly Typed Html Helper in jquery?

I've mostly worked in MVC1. I'm now working with some MVC2 code. I have fields with Strongly Typed Html Helpers like: <div class="editor-field"> <%: Html.TextBoxFor(model => model.Contract.client_name)%> <%: Html.ValidationMessageFor(model => model.Contract.client_name) %> </div> How do I acce...

OData (WCF Data Service) with Subsonic 3

Hi all, I'm trying to use WCF Data Service with Subsonic, but ran into this error when I try to access my "service.svc". I have 2 projects, one is a class library (called "OData") that has Subsonic t4 templates to generate the classes for my table. Another is an ASP.NET MVC2 project that references to the "OData" project. I then create...

Asp.net MVC 2 How customize my Model in Framework Entity. Issue For multilang app.

Here is a multilang table design. Is it possible to add a method for my CategoryText model to give me the CatName for a specific langID. LangID will be chosen by the customer and set in Session variable. EXAMPLE :I would like to get the category name like this var a = _db.Categories.Single(a=> a.AreaTypeID == 2); string CatName = a....

Display time padded how Stackoverflow and Facebook do - C#

I have a ASP.NET MVC 2 app I am building and users are allowed to post data in certain sections. I would like to display the "Posted At" in the same format that Stackoverflow and Facebook do. i.e. On this site when I post this question it will display "asked 3 seconds ago" then "asked 3 mins ago" and after a few day it will display the...

How to use Asp.Net Async Controller for concurrent processing if the number of concurrent items depend on the user's settings?

I want to create an async version of my page to speed it up. However, the number of async requests I need depends on the user's personal settings. For example, I have a dashboard that can display numerous things. I want to do something like this: public void IndexAsync(string city) { AsyncManager.OutstandingOperations.Increment(3); N...

Sending parameters in AJAX call

This has been asked before by others, but I have not been able to use their answers. I am trying to sending some data by doing the following: function addForumPost() { var title = jQuery('#forumTitle').val(); var message = htmlEncode(jQuery('#message').htmlarea("toHtmlString")); var tagNames = addTa...

JQuery, updating form and exception if update it more then once

I've got index of my elements: <h2>Index</h2> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt; <script type="text/javascript"> $(document).ready(function () { $('button').click(function () { $.post("Home/Swap", $("#log...

Why is my ASP.NET MVC 2 application reporting "The resource cannot be found."?

I deployed my first ASP.NET 4.0/MVC 2 application onto a staging and test server. The problem is that when I browse to the application I just get the ASP.NET 404 "The resource cannot be found." page. The application was written using: Visual Studio 2010 Premium Target Framework: .NET 4.0 ASP.NET MVC 2.0 The application is deployed o...

NHibernate - How to handle the NonUniqueObjectException?

I get this error: a different object with the same identifier value was already associated with the session: 63, of entity: Core.Domain.Model.Employee Within my ASP.NET MVC controller actions I do this: public ActionResult Index(int? page) { int totalCount; Employee[] empData = _employeeRepository.GetPagedEmployees(p...

ASP.NET MVC2 Custom RoleProvider GetRolesForUser not called

Hi everybody, I have a situation with my ASP.NET MVC 2 application that when I use [Authorize(Roles = "Admin,User,Test")] attribute on any of the controller methods, my custom role provider is not called. Tricky part is that when I run the application in visual studio web dev server, this GetRolesForUser is called every time. When I ins...

Having trouble starting my very own MVC tutorial-sans web application.

I'm having trouble trying to understand what to do here. My objective isn't as simple as a regular old CRUD form to create a new entity, but rather a browse index page that will list all of the Evaluations in my database. Each evaluation is attached to a RegisteredCourse which in turn has a Teacher attached to it. Here is how I'd like...