asp.net-mvc

Partial page return with MVC

I am pretty new to MVC and hope that I am approaching this the correct way. Any input or advice would be great. I would like to have a thumbnail view of an image load normally and when a user clicks on the image, the dynamic picture loads using the colorbox jquery plugin. The problem is when you click on the smaller image, the dynamic...

What's a good approach for building a calendar / event application (view)?

I would like to build a calendar 'component' for my website. I want to make it manageable and easy to extend in the future. I will not be using it for any other website but it want to make it solid independent of the rest of the website. The website is built with ASP.NET MVC. I want to include different views (month, week, day [maybe ev...

Pass SelectList "SelectedValue" to Controller Action Method

I have a registration form which displays a users Name (textbox), Email (textbox) and Division (SelectList). The Name and Email are pre-populated (I'm using Windows Authentication, Intranet app), and I want to send the SelectedValue from the DropDown to my controller as an Int32, I don't want to send the entire SelectList back. This li...

How are forms prepopulated in ASP.Net MVC?

When you have an ASP.Net MVC form created by Html.BeginForm(), how do fields inside it get populated? In the case of <asp:Content ID="Main" ContentPlaceHolderID="MainContent" runat="server"> <h2>Edit Dinner</h2> <%= Html.ValidationSummary("Please correct the errors and try again.") %> <% using (Html.BeginForm()) { %> <p> <labe...

ASP.NET MVC: Using Kigg as a base MVC application

Looking to create my first MVC application. Coming from WebForms I'm pretty excited to create an application that I can easily test. I have looked into Kigg (the Digg clone done in MVC) and from the looks of it, it uses many of the best-practices in its architecture. Having said that, would their approach be a good basis to base my we...

Where do form fields in ASP.Net MVC take their values from?

I understand that fields such as Html.TextBox() accept two values, the first one being the name and the second one being the value. And so does Html.TextArea(). But in a case where the form is submitted as AJAX and the div where the form is placed is replaced with a view from the server, the form fields insist on taking the previous valu...

Self-AJAX-updating partial-view/controller in ASP.Net MVC and the duplicating div

I have a partial view in MVC that goes something like: <div id="comments"> ... </div> Inside that div there's a form that calls a controller using AJAX and gets back that same partial view. The problem is that the results of calling the view replaces the contents of the div, not the whole div, and I end up with: <div id="comments...

Problem with repository creation in C# and ADO.NET entities

Hi everyone, I'm building this app at night after work and have been struggling with this design problem for a week or two now. I'm building a program that has 44 different types of entries and requires the ability to create a custom type. Because users might change the fields in a particular type of entry and/or define their own, my ...

MVC: How to work with entities with many child entities?

In the current examples on ASP.NET MVC I see quite basic entities, with simple CRUD methods. But I'm not sure about what to do with more advanced models. Let me give an example: We have a garage website. The garage has: Inventory with carparts Employees Customers Cars that consists of all cars that are/were in the garage Now lets ta...

ASP.NET MVC, jquery ajax, real simple history

I'm working on a mvc application that uses jquery to implement dynamically loading page content using jquery.load and/or jquery.ajax. But when the user uses the back button in these kind of applications, the result for the user is often unexpected. I've seen articles like RSH from google that claim to solve this problem, but I'm not sure...

Having problems with ASP.NET MVC and StructureMap.

Hi folks, I've got StructureMap working fine on my machine. Everything works great ... until I request a resource that doesn't exist. Instead of a 404, i get a 500 error. eg. http://localhost:6969/lkfhklsfhskdfksdf Checking the net, i was told to fix my structuremap controller class. Did that and joy! i now get the -original default 4...

MVC App works in IIS 7, does not work in Cassini (IIS 7, too)

hi, i have a mixed app (asp.net webforms, later mvc added) and it runs in iis 7 on vista but does not run on cassini on the same box and with the exact same files in the webroot. actually, webforms work as expected but all mvc routes are 404. what can i do to diagnose this issue? ...

How to dispatch on the result of submiting an AJAX form in ASP.Net MVC?

In ASP.Net MVC, having a form more or less like this: <% using (Ajax.BeginForm(new AjaxOptions() { OnSuccess="onSuccess"})) {%> <p> <label for="Comment">Comment:</label> <%= Html.TextArea("Comment")%> <%= Html.ValidationMessage("Comment", "*")%> </p> <p><input type="submit" value="Submit comment" /></p> <% } %> How c...

How do I add a MVC route to a specific controller?

My mind is somehow blank. How do I do this: I have a RegistrationController and want the URL /register to hit the action Register on that controller. What do I have to add as a map route in global.asax? ...

What's with the line break variations in C# and ASP.NET? (\r\n vs.\n)

I've been writing code for ASP.NET since the start, and today I encountered something I've never seen before. Typically I've looked for line breaks in C# (when posted in ASP.NET from a textarea, for example) by expecting "\r\n". Now I'm using the MVC framework, and the text coming over the wire from a textarea simply has "\n" for line br...

Entity Framework Foreign Key (or lack thereof)

So I have pouring of this code forever, trying to figure this out... I am using Entity Framework 1.0 with ASP.NET MVC in .NET 3.5 SP1 with EFPocoAdapter (so separate Poco classes). So I have the following code for one of Controllers: [AcceptVerbs(HttpVerbs.Post)] public ActionResult EditUser(int? id, FormCollection form) {...

C# MVC: What is a good way to prevent Denial Of Service (DOS) attacks on ASP.NET sites?

I'm looking for a good and inexpensive way to prevent denial of service attacks on my ASP.NET MVC site. I've been thinking about a solution that intercepts the HttpHandler and then counts requests in the Cache object, with the key being something like "RequestCount_[IpAddressOfRequestClient]" but that seems like it would generate a cra...

How do I access the ModelState from an ActionFilter?

I'm building an ActionFilter to reuse some code for a simple spam block - basically what I do is that I have a Html Helper method that renders an input textbox and a hidden input, and in the ActionFilter I check whether the two values are the same or not. If not, I want to leverage the rest of my validation logic and add a ModelStateErro...

Request for Tutorial to add Openid Support to NerdDinner ASP.NET MVC application

I'm looking learn about ASP.NET MVC and OpenId using the ASP.NET MVC NerdDinner tutorial. I would like to replace the Authentication system in NerdDinner to be OpenId only. I've downloaded the latest DotNetOpenAuth libraries but I'm not sure how to put it all together. Can anyone help with a quick step-by-step tutorial? Is this as simp...

ASP.NET MVC: Page-specific logic

There has been many discussion on ASP.NET MVC and Codebehind-files, mostly where it has been pointed out that these Codebehind-files are evil. So my question is, how do you handle page-specific logic? What we don't want here is spaghetti-code in the inline-code and we don't want page-specific code scattered throughout helper-classes or...