asp.net-mvc

Generate links in ASP.NET MVC?

I have the following route definition in a MapRoute Table: routes.MapRoute( "ViewDocument", "browse/document/{document_id}/{document_title}", new { controller = "Document", action = "ViewDocument"} ); I have to create links of documents on document index view (document object have "id" a...

What is the most enjoyable literature that is also useful for developers at a technical level?

I just spent some time at Bart de Smet's online blog and found it to be not only useful information for developers but at the same time interesting, fun, reading. The author obviously not only knows his subject matter, but has a talent for making his writing enjoyable to read: ...80 centimeters behind me lies the answer in dead tre...

ValidationMessage - Handle multiple errors for the same property

I'm using ValidationMessage control in MVC. When validating each property, it may have more than one error message to show, but the ValidationMessage only displays the first error message in the list. Here is an example: ModelState["Key"] = new ModelState(); ModelState["Key"].Errors.Add("Error 1"); ModelState["Key"].Errors.Add("Error 2...

Error trying to populate a drop down list during a "GET" create action

Hi, I am trying to understand something a bit better with being new to C#, .NET 3.5 and MVC. I am running through the MVC NerdDinner example and if you look at the ViewModel here: http://nerddinnerbook.s3.amazonaws.com/Part6.htm#highlighter_662935 You can see the Country list and how it gets populated, this seems to work fine but I tri...

How to do Authorization redirect on ASP.NET MVC

Hi Everybody. So, I come from a ASP.NET 2.0 WebForms background and am new to ASP.NET MVC which I find it wonderful, however, i've been somewhat accostumed to it. This time, my problem has to do with Authentication and Authorization Model: I used to restrict folders via Web.config's authorization section <authorization> <deny user...

MasterPage/ContentPage with NVelocity and ASP.NET MVC?

I am a big fan of NVelocity. I think its terse syntax is a huge boon, and helps keep my views simple and effective. I have begun using the NVelocity view engine from the Mvc Contrib project for ASP.NET MVC, along with the Castle NVelocity .vm syntax highlighter. While I love what NVelocity brings to the table, I am really missing one f...

How to whitelist/blacklist child object fields in the ModelBinder/UpdateModel method?

...

C# MVC: View with optional ViewModel (data not always present / necessary)

Hello, I'm kind of stuck on an MVC problem. I have a registration view, reached by www.example.com/register, something like this: <form id="registrationform" method="post"> <fieldset> <label for="emailaddress">Email</label> <input id="emailaddress" name="emailaddress" type="text" /> //more inputs etc. </fieldset> </form>...

registration - Extra information

When registrering a Item for sale (Car, cellphone, motorbike, computure) there is a DropDownList. Containing all the Categories. Some of the categories have extra informations boxes. If the category: car with value=100 is selected then we need to fill extra information: year, make, model .... Motorbike is selected with value 102. year...

Create a record where the Model inherits from another Model

How do I set a models reference property correctly? I have a Model called Platform which has a navigational property to a model called Service. The issue I am having is with setting the value of platformToCreate.Service. Here is a screenshot of the Platform table: Here is a screenshot of the EDM: Code: [ValidateInput(true)] ...

Presentation class vs Interface for View Filtering

Why use a Presentation class instead of an Interface when filtering model properties for submission to View? ...

C# MVC: Performance and Advantages of MVC Html Helpers vs. Direct HTML in views

Hello, I'd like to know what kind of performance impact Html helpers have on C# ASP.NET MVC views, especially when setting attribute parameters, and what kind of advantages they have overall (why use them?) With Html Helpers: <%= Html.TextBox("firstName", Model.FirstName, new { @disabled = "disabled", @class = "myCssClass" }) %> ...

Fill a calendar with appointments

In .NET MVC (C#) I need to create a calendar and fill it with events that come from a database. Most events are spread over multiple days. What is the best approach to create such a calendar? Does a calendar control exists which takes some input arguments and can do the work for me? ...

set active accordion in Jquery

I am using MVC with C# also with jquery. I am using an jquery accordion to see the list of employee details. On clicking an accordion it'll show the employee details. When i click Edit of an Employee, it takes to the Employee details page and after save it'll have the EmployeeDetailsID in session. When i come back to the accordion page...

ASP.NET MVC MembershipService Email

I have been working on an MVC project and I everything works at the moment except I can't force the user to confirm the email address before I active the user's account. I am using the built-in MembershipService/MembershipProvider that came with MVC. I was thinking of sending a normal email using an SmtpClient and MailMessage and then m...

MVC naming conventions for JSON actions

What naming convention is recommended when writing an MVC app that has both front-end and JSON paths to the required data? For example, let's say the user of your site has "Things". They should be able to go to a page to view their things, but we also need a way to pull those things back as JSON on other pages. I've been able to think...

Compiling views when publishing asp.net mvc project

Is is possible to compile asp.net mvc views into one assemply when publishing web project? ...

Elmah basic setup questions/issues ...

I'm not finding this to be easy to setup; either there is a missing step in the setup configuration, it isn't work correctly, or I don't actually understand it's purpose. There is something definitely wrong here. The problem must obviously be me. I'm just not getting this to work. Here's what I've done. Create a brand new mvc applicat...

ASP.NET MVC Controller.OnException not being called

I have a base controller class where I'm overriding to the Controller.OnException handler method in order to provide a generic error handling for certain types of controllers that will inherit from this class (these are API controllers that will return JSON results). The OnException method never gets called when an exception gets raised...

Master Pages.. and applying a css classes to the body element

I have a master page which a generic a menu that looks like this: <div id="menu"> <ul class="sf-menu"> <li class="menuHome"><a href="/home">Home</a></li> <li class="menuBandsAZ"><a href="/artist/list">Bands</a></li> <li class="menuGigs"><a href="/gig/list">Gigs</a></li> </ul> </div> <asp:ContentPlaceHolder ID="ListingPlaceHolder"...