asp.net-mvc

Building a complex Object step by step. Where to save it?

Hi, I am using ASP.NET MVC. My requirement is to build a complex object (an object made of other object) through a step-by-step procedure like in a wizard. Every dependent object shall be build on it's step and shall be validated in it's step. For example public class ComplexObjectModel { public Object1 MyObject1 { get; set; } ...

How to concisely create optional HTML attributes with razor view engine?

I'm looking for a way to write the following code with less lines of code (maybe 5). I suppose I could do the same thing as the selected class but this razor syntax isn't looking pretty. <ul> @foreach (var mi in Model.MenuItems) { <li@(mi.Selected?" class=\"selected\"":null)> @if (string.IsNullOrEmpty(mi.Title)) { <a href="@mi....

ASP.NET MVC 2 Ajax Site Master

I started with a "new ASP.NET MVC 2 Web Application" template and created a few controllers. I want the links on my navigation menu (located in Site.Master) to load my 'content' div (which has all of the controller output) via AJAX and not perform an entire page refresh. I return PartialView() from TestController Index() method but this...

MVC Partial Rendering with page loading optimizations and Content Placeholders

I have been trying to organise my views to optimize load times by having css in the head and scripts at the end of the body. To this end I have created masterpages that have 3 content placeholders: styles, maincontent and scripts. With the (achieved) aim that when I render a single view with a master this neatly can collate all the share...

Toolkit for Asp.net mvc

Does anyone know asp.net mvc toolkit which has a ready tools for typical web developnet tasks(paging, comments, profiles, messaging, etc....) ? ...

ASP.net MVC Membership Redirect Depending on Role

I have two types of roles [Admin, HelpDeskAdmin]. I have a single logon view(both users go to same link to login) and I want to check their role once logged in and redirect to their respective admin pages once authenticated. The code below doesn't identify the logged in user as being in the role the first time and reloads the logon pa...

Problem to catch REQUIRES_AUTH and xhr.status from HttpContext.Response

Trying to find solution for redirection to the login page after Ajax-call if a user is not authenticated longer. I used a method described here http://stackoverflow.com/questions/199099/how-to-manage-a-redirect-request-after-a-jquery-ajax-call private static void RedirectionToLogin(ActionExecutingContext filterContext) { string red...

how to gzip content in asp.net MVC??

how to compress the output send by an asp.net mvc application?? ...

Can i pass a Model from view to controller without Form?

Hi guys i have difficulties of passing my model to controller> I wonder if this is a good practice or is it possible to do so. Here's what i want to achieve. <% foreach (DownloadFile file in Model){ %> <a href="<%= Url.Action("DownloadFile", new { File = file}) %>">click here to download</a> <% } >% I want to pass the DownloadF...

MVC Grid with a datepicker - what is the best way?

I have previously asked how to put a datepicker in a grid, and I did not get a response. I found that the way I did it didn't work, becuse the ID of all the fields in the same column was the same. So when I put in a date, only the first field in a column got updated. I sent a message asking how to set the ID of a field to prevent this, b...

Html.ActionLink() != Html.BeginForm() for URL prefix

Hi all! This is my setup: IIS6 on Windows Server 2003 iirf URL rewriter mapped .mvc extension to handle MVC pages (unchecked verify that file exists) no jolly catch-all handler IIRF rewrites with the following rule (there is more, but it all boils down to this one, as far as MVC is concerned): RewriteRule /(.*) /mvc.mvc/$1 [I,L] ...

sharing data among controllers and pages

how to share data among all web app like session . i have used session but value getting lost when i make any next request don't know weather i am making mistake or what. just want to share data among all app after fetching once from database at login time. (like session do without breaking MVC rules) thanks no different application in...

elmah default error handling

hi ppl. i'm using elmah in a asp.net mvc application and i'm trying to pass the error id from global asax to the controller action responsible for the handling of errors. i want to show the error information if the exception is a custom exception. but i'm stuck... first of all i'm using the event handler in global asax like this voi...

MVC.net. Sequence of asynch calls of controller methods

Hello, I work on MVC.net application. I make asynch requests to my controller via jQuery. Below you can see these requests in fiddler (all of them are fired in a specific sequence). num result protocol Host URL 2929 200 HTTP somesite.com:1936 /DynamicTables/SaveCurrentRowsState 2930 200 HTTP som...

Shorter way of writing data to a view

Hi, I'm trying to find out if there is a shorter way of writing data to a view than what I am currently doing. This is what I currently have in my view: <td> <% if (Model.AnnualIncome != null) { %> <%: "R " + Model.AnnualIncome.ToString() %> <% } %> </td> Is there a shorter way of ...

ASP.NET MVC + Elmah - Resource not found

I'm trying to implement ELMAH in my ASP.NET MVC application, but I'm having a problem that caused me to lose hours and hours ... and it's still unsolved. My application is running normally, but when I try and configure ELMAH and them access Home/Index, the application returns me a 404 (Resource not found). Has anyone had this problem an...

asp.net mvc c# Request.Files[0].ContentLength getting zero internet explorer

The file size validation is not working in Internet Explorer, it worked fine in FireFox. It is posting at octet in Internet Explorer, what could be the reason? Session["ContentLength"] = (Request.Files[0].ContentLength / 1024); Session["ContentType"] = Request.Files[0].ContentType; byte[] b = new byte[Request.Files[0].ContentLength]; Re...

Asserting return type of MVC Controller Action

How can you assert that an expected type is returned when it is wrapped up in a System.RuntimeType? As part of a larger unit test to verify that an action has the correct parameters and action filters assigned I'm asserting against a populated instance of MethodInfo. When I assert against "action.ReturnParameter" it fails as it's say...

MVC 2. My page jumps to the right when I change my selection in a dropdownlist

I am using nested master pages, which may or may not cause the problem here. My view looks like this; <asp:Content ID="Content2" ContentPlaceHolderID="AdminAccountsContent" runat="server"> <% using (Html.BeginForm()) {%> <h3>Christmas Shutdown Administration</h3> <p>Before entering the Christmas shutdown dates...

ASP.Net MVC SQLExpress Production Environment Update Scenario

New to actually deploying a Asp.Net MVC web application with sqlexpress in the App_Data folder, how would I handle database updates after it is live and in use. Here's my scenario and a few questions: I have an Asp.Net MVC 2 Web app w/ sqlexpress databases: [myappData.mdf, aspnetdb.mdf]. I was planning on publishing this to the produc...