asp.net-mvc

ASP.NET MVC Field naming convention for nested objects

I am using ASP.NET MVC 1.0. I am creating a view to Create a new object of the following class public class ClassOne { public string Name {get; set;} public string Id {get; set; } public CaptionItem Caption {get; set;} } public class CaptionItem { public string CaptionSet {get; set;} public string Text {get; set;} }...

How to dynamically create routes in a HTML actionlink

I am trying to send the route values to a method but I cant seem to figure this out. Here is my code <% string s = "cool"; object d = new { s = "1" }; %> <%= Html.ActionLink("Home", "Index", d, "ql")%> The following code produces a url like this http://localhost:49450/?s=1 the url should be like this http://localho...

Using ASP.NET MVC2, How to make filters work with hackable urls?

Think about New Egg's e-commerce drill down model to start, where keyword links on the nav bar further limit the currently displayed product list with each selection. I setup a house finder with Routes like this: http://{website.com}/{Housetype}/{PriceLow}-{PriceHigh} http://mysite.com/Residential/180000-230000 http://mysite.com/Commer...

ASP.NET ViewModel Alternative

In Django/Python, if I had the following model class Model1: id = char field name = char field creation_time = datetime field I can create a form (view model) like the following class Model1Form(Model1): exclude = {'id', 'creation_time'} I then pass it into a view/template and it would ignore id/creation_time In...

voting - stopping abuse from client side - ASP.NET MVC

so I have designed this voting thing which does not let somebody vote for the same article twice in 24 hours. However, suppose a person votes and after seeing the person was able to cast vote or that he is falling in that 24 hour window, I disable the vote-casting button (and this is all Ajax btw). But what to do when a person closes h...

Using TR instead of DIV for AjaxOptions UpdateTargetId?

basically, i have a Comments.ascx and a Comment.ascx file, and do the typical For Each loop to display comments using both files... Now, as you'd expect, the Comments.ascx contains the header stuff, like this... <table> ... </table> and in the middle (the Comment.ascx file), i have the typical... <TR><TD>....</TD></TR> type stu...

ASP.NET MVC Dialog Stumped

I am using jQuery's UI dialog to open a basic form. I want to submit that form and close the dialog. I am having trouble. The parent window opens the dialog (which contains a partial view) from click and form is submitted, they the browser opens the partial view in the browser. I want it to do the form work and close the dialog. Is th...

ASP.NET MVC Ajax.BeginForm returns unexpected results

Hi, I am rendering out a partial view like so: <div id="cart"> <%Html.RenderPartial("Cart", Model); %> </div> For each line in the cart I am using a form to remove items (it is important that this works when javascript is disabled hence no Ajax.ActionLink): <%using (Ajax.BeginForm("RemoveFromCart", "Cart", new AjaxOption...

How to handle model state errors in ajax-invoked controller action that returns a PartialView

I have a POST controller action that returns a partial view. Everything seems really easy. but. I load it using $.ajax(), setting type as html. But when my model validation fails I thought I should just throw an error with model state errors. But my reply always returns 500 Server error. How can I report back model state errors without ...

Best way to populate ViewData for DropDownLists in Asp.net mvc?

What is the best way to populate ViewData for the dropdownlists which are used in multiple views. If it is done in each and every Action that uses the dropdowns then we are violating the DRY principal. Also ideally we should be caching the regularly used SelectLists (e.g Countries, States etc). ...

How to automatically publish a website on build in Visual Studio 2008?

I want to be able to automatically publish to a local folder each time a web asp.net mvc 2 project is built. I use Visual Studio 2008. ...

ASP.NET MVC 2 blog post seems to discuss nonexistent attributes

Reading this Brad Wilson blog post, I'm coming across several attributes (e.g., DisplayFormatString, EditFormatString, ShortDisplayName, SimpleDisplayText) that seem to have no available documentation, and I'm having no luck figuring out what namespace they belong to. Do these attributes even exist? Have they been replaced by different ...

asp.net mvc - where to store userid - integer?

I got the vibe using session variable is sort of looked down upon in ASP.NET MVC. Once a user logs in, I would like to retain the user's userId so that I do not have to query it all the time etc. What is the most efficient way to do that in ASP.NET MVC? ...

Debug Toolbar for ASP.NET

Is there something akin to the 'Django Debug Toolbar' for ASP.NET (and more specifically ASP.NET MVC). It's an HTML page overlay that shows total execution time, SQL queries (and time), what views were called... etc. ...

mvc render view to string span

Hi, I previously grabbed some code from "http://stackoverflow.com/questions/1281430/rendering-a-view-to-a-string-in-mvc-then-redirecting-workarounds", now below is the code that I'm using to display the html of a page as content inside a email body and also use "javascript:document.print;". The problem is that I have some Span's that b...

ASP.Net WebForms or MVC which is right for me as a .Net newb?

I am aware of the differences between webforms and MVC, I am trying to determine in which environment I will feel most at home but yet not in over my head. I have been building web apps for 9 years in ColdFusion using an MVC design pattern. I am used to having full control over the rendered HTML & CSS as well as utilizing the jQuery li...

ASP.NET MVC Routing and Structure

I have a Customer list that will have Invoices and Emails linked to it. I have my customer/details/1 and customer/edit/1 working as per the default route but would like to have it instead be like below customer - Lists customers customer/1/edit - Edit Customer ID 1 customer/1/details - Details of Customer ID 1 customer/1/invoice...

Linq to Entity Model's DataAnnotations don't reset

In my Asp.net MVC app, I have a custom validator class V and an (ADO.NET Entities) entity model E. class V : ValidationAttribute { public override bool IsValid(object value) { ... if (hasErrors) ErrorMessage = errorMsg; ... } } public partial class E //the entity m...

Using asp.net site.master and spark views

Is it possible to use my site.master master page ? I want to start using Spark more, but this project I am working on is using asp.net view pages as well. I could of course convert the master page to an application.spark page, but I was wondering if it is at all possible to use the Site.Master I already have. ...

Entity Framework object limitations in aggregate LINQ query

I have a rather complicated query that I'd like to have return some particular types. Mostly concerning date / time calculations or string values, the Entity Framework seems to be spitting the dummy when I try anything further than a System.DateTime type: The specified type member 'Date' is not supported in LINQ to Entities. Onl...