asp.net-mvc

Getting the SubSonic MVC Templates to work with my database.

I downloaded and installed the SubSonic MVC templates. I'm able to create a new project from this template and the 'prewritten' views work fine. I'm able to edit records from the Artist table of the included 'Chinook' database. So now I'd like to get this to work with MY database. Here's what I've done. Changed to connectionstring in...

What HTML element should I use for when a user must select multiple items out of a large list in ASP.NET MVC?

I have a form for lawyers where they need to be able to select which states they are licensed in. So, they need a clean way to be able to select a few states from all 50 states. What I'm not sure is, how to handle this in HTML. Is there some possible way to have a drop down of checkboxes or something similar? I'm using ASP.NET MVC. ...

asp.net MVC Storefront showing too many queries?

I am studying Asp.NET MVC Storefront application and there is some help needed with LINQ. For example study this Partial Code. Here is GetCategories Function which retrieves All Categories and their corresponding Products. In a View I only needed Category Names but when called this Function and checking in SQL profiler it shows too many ...

ASP.NET MVC 2 - HTML.EditorFor() and Custom EditorTemplates

With MVC 2's addition of the HtmlHelper EditorFor() it is not possible to create strongly typed Display and Editor templates for a given Model object and after fiddling with it I am a bit stumped as to how to pass additional Model data to the editor without losing the strong-typing of the editor control. Classic Example: Product has Cat...

ASP.NET MVC Open Source Real-world Apps

Whenever I start learning a new technology or language I tend to look at the source code of some 'real-world' applications. I find them really useful for understanding common, technology specific architecture, idioms and how/what popular libraries are used. I've recently started learning ASP.NET MVC, but haven't really found good open so...

SubSonic3 clearing test data/database in unit test TearDown operation

I'm writing some unit tests for an ASP.NET MVC controller that's using SubSonic3 generated model objects (using ActiveRecord "mode" (not sure what else to call it), and am wondering how I can clear out the test data from the test database in my TestFixture's TearDown method. I don't have a direct reference to the model object in my test ...

ASP.NET MVC C#: Bringing in data from multiple tables/queries into a view

Ok, I'm still getting the hang of asp.net and the MVC framework and converting my knowledge over from classic ASP and VB - so please be gentle. I've got my first view (/home/details/X) functioning well thanks to previous help pointing me in the right direction, now I need to add data from multiple tables and queries/views to the MVC vie...

asp.net mvc 2 preview - Templated Helpers linq to sql

I'm checking out these neat Templated Helpers that have juts been released with the latest preview of ASP.NET MVC. I notice that I can decorate the classes as required, but I'm thinking it will get a bit messy with Linq 2 Sql if I have to keep re-generating the classes when I make schema changes. Does any one have a recommended approac...

how can i avoid unmaintanable code in asp.net mvc views

i am finding more and more my asp.net mvc views are starting to look like my old crappy asp code that i could never maintain or keep clean with integrated <% %> and html put together. below i have a code sammple of what i am talking about. is there any best practice or recommended way of avoiding this and keeping the views more maintab...

How can I validate all the code enclosed between the <% and %> brackets of aspx files at build time?

I'm starting to use Asp.net MVC. It is recommended to use the <% and %> tags to embed the source code in the HTML, since it's easier to read. Unfortunately though Visual Studio can't detect any errors in the code at compile time. This is a very bad thing. For example: <body> <form action="LogOn.aspx"> <div> <d...

ASP.NET MVC: Best practices for keeping session state in a wizard-like app

Let's say I have a Web application implemented like a set of wizard pages to edit a complex object. Until the user clicks on the "Finish" button, the object doesn't get saved to the back-end system (a requirement), so in the meantime I have to keep the whole information about the object in some kind of a session state. Also, some of the...

Why does Intellisense not work when using render blocks on an HTML attibute with double quotes?

When I try to write code like the following source code, Visual Studio doesn't show any Intellisense for current context. Moreover, it tells me that another "<% %>" brackets is incorrect. <div> <input type="checkbox" title="<%= LogOnView.RememberMe_ToolTip %>" /> </div> How to solve this problem by patch or VSPackage(if you have ...

Where to place jQuery code in ASP.NET MVC view page?

I have just started to learn jQuery + ASP.NET MVC. Whatever tutorials I have read about jQuery, they suggest that all jQuery code should be in head element. Now in the ASP.NET MVC project, I have one master page which is responsible for head element. In other view pages, I get content place holder which draws in body element. I am conf...

How can I use JQuery tablesorter plugin into ASP.NET MVC Partial View? When I insert PartialView in View, I'm using ajax.

I have View with table and JQuery tablesorter plugin. It works very well. But, when I try insert table and tablesorter into PartialView and insert this PartialView into View page with Ajax, tablesorter doesn't work. Into Partial View dont't work jquery. Plugin doesn't get called. My controller code: public ActionResult MyTable() ...

how do i replicate the stackoverflow close button click to replace confirmation pages in asp.net-mvc

i have taken over an asp.net mvc and i there are a lot of actions that require user confirmation. The current implementation is to have a separate View for each of these confirmation pages. i thought it would be slicker to use jquery to have a little popup when you click "delete user" for example that shows the user confirmation there ...

MVC Model Binding IList<T> data to Html.Listbox

Hi, I want to bind my Store class which has multiple Products to Html.Listbox. While in edit Store mode, I want Html.Listbox show all products where products of the Store are selected. I could not manage to bind store.Products to the listbox My class structure; public class Store { public virtual int Id { get; set; } public vi...

Apply zebra striping to jQueryUI accordion

I have a asp.net mvc app building a accordion based on the jQueryUI Accordion plugin - I'd like to apply zebra striping. Here's the constructor loop: <div id="accordion"> <% foreach (var webinar in Model as IList<Webinar>) { %> <div id="accordionItem">//toDo: Programmically pick odd/even rows ...

Register all Controllers programatic in Castle Windsor container from all assemblys

I use this code... container.Register( AllTypes .FromAssembly(Assembly.Load("MyNamespace.Dashboard")) .BasedOn<IController>() .Configure(component => component.LifeStyle.Transient .Named(ControllerNameFromType(component.Implementation))) ); ... to register...

Check user's details in ASP.NET MVC ActionFilter

Hi! Let's suppose I don't want to use Membership and want to restrict user's access with ActionFilter. I know I can create a filter/attribute and override the OnActionExecuting method and further I can put this attribute in a ActionResult. And let's assume that I have a table named 'tbUsers', it has also an int field named 'certifica...

Serving a view as a file in asp.net mvc

Hello, I'm trying to send a view that contains a html table as a downloadable file to the user, as an excel file. I keep getting the error "Server cannot set content type after HTTP headers have been sent.". I can't figure out what's going wrong... Here's some code: Excel.aspx: <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPa...