asp.net-mvc-2

MVC 2 - How to exclude multple columns in the create method.

How can I exclude multiple columns when creating a new customer? The other column is the date that the record was created - called customer_dt. public ActionResult Create([Bind(Exclude = "customer_id")] Customer customer) { /* Do something here ... */ } ...

Populating / implementing RadioButtonListItem items in a RadioButtonListViewModel from a database

Hi All, I'm a total noob, so forgive me in advance if there's something very obvious I'm missing here. I'm working on refactoring some Web applications from ColdFusion to ASP.NET MVC 2. I'm trying to create a radio button list based on this article: http://stackoverflow.com/questions/2512809/has-anyone-implement-radiobuttonlistfort-f...

MVC2 - Are There Signals for Models?

I'm just starting on my first ASP.NET MVC project (it's actually extending an existing MVC project that uses 4.0 and Linq2SQL). What I'm looking for is a way to create an instance of a model every time a different model is created (i.e., saved to the database). I see an OnCreated() method in the generated code, but that's in a partial cl...

Using asp.net <%: %> syntax to generate javascript in an MVC application

I have a for loop to loop through my list of SliderItems which contain an ID, ImageUrl, and a link Url. <% foreach (var item in Model) { %> <a href="#"><img id="<%: item.ImageID %>" src="<%: item.ImageUrl %>" class="slide" alt="" /></a> <%} %> I need to loop through and generate the data parameters for this javascript automatical...

Need help preforming an XSL Transform from XML to HTML in ASP.NET MVC

I just learned about XSL and XSLT a few days ago and now I'm trying to put it to work based on a question I had earlier today (want to have formated XML displayed on my website). Here is the code I'm trying (in a View): XDocument xmlInput = XDocument.Parse(item.Action); XDocument htmlOutput = new XDocument(); using (System.Xml.XmlWrit...

ASP.NET MVC 2 - DropDownFor -- Force user to select a value for a non-nullable type?

Hey all, I have (or so I think!) a simple problem. I will greatly simplify my model to speed this along. I have a model class lets call it item: public class Item { [Required(ErrorMessage="Must indicate if product is to be tracked by serial number.")] public bool TrackedBySerial { get; set; } } I have an "Add" view wh...

How can I display a link and not a button to submit my ASP.NET MVC2 Form

Hi, I'm just starting out in ASP.NET MVC (and web applications in general, as I've only really worked on console apps before), and was wondering how to display a link instead of a button for submitting a form? Thanks. ...

Not seeing roles on Principal in ASP.NET MVC 2 Application

I am writing an ASP.NET MVC 2 application and don't want to use ASP.NET Membership. I do want to use the Authorize attribute on the Controllers. What I have done so far is ... Web.config <roleManager enabled="true" /> <authentication mode="Forms"> <forms loginUrl="~/Authentication/Login" timeout="2880"/> </authentication> <authoriza...

ActionLink with routeValues creates old-skool style URL

Dear SO surfers, I have a route defined as such: routes.MapRoute( "CustomerWithScreenName", // Route name "Customer/{sn}/{action}", // e.g. Customer/KingKong89/Schedule new { controller = "Customer", action = "Signup", id = "" } // Parameter defaults ); But when I formulate a link using ActionLink like...

MVC 2 Application with a relational DB and object wrappers - how to get relational data into views?

I've recently refactored my application with the following: Linq to SQL db connection Objects to wrap the linq to sql classes Mappers to map back and forth between objects and Linq to Sql entitys Service layer to call the repository, handing up objects to the UI. Before I was just using Linq to SQL objects in my UI (I know). But when d...

how to display the item in the listbox using jquery

hello Friends, I need to display the Items in the Listbox with Checkbox for each item. using jquery or asp.net mvc? can any body tell me how to do this kind of thing? thanks ...

MVC: How to encapsulate logic in MVC ascx partial view with the same efficiency of webforms ascx controls?

Hi, I have to build a few ascx partial views in my MVC applications to encapsulate re-usable functionalities as well as archive SOR and SOC. However, I encountered challenge how to encapsulate the business logic that drives MVC ascx views. In webforms, the code behind of an ASCX control can handle a button click event and browser stil...

Listing Count per "Category" for IQueryable

Hello I have an mvc-page that lists categories, and I would like to have it to count the number of products per category. It's IQueryable. <% foreach (var item in Model.Categories) { %> ..... <td><%: item.CategoryName %></td> <td><%: item.Products.Count() %></td> It lists: 5 5 Instead of: 3 2 Any Ideas how I can "partition" it per ...

MVC 2.0 Test Https locally

How i may test ssl with mvc locally using IIS 7.5. Because by default when if i set RequireHttpsAttribte to controller in response i am getting : The requested resource can only be accessed via SSL. ...

how to hide any page element with mvc2 validation raising in asp.net

I want to hide a span when the validation raised ...

MVC2: what is the easiest way to postback from TextBox

I need to update an element on the page based on what the user is typing, while the user is typing (i.e. without having the user to click submit buttons). Similar to how StackOverflow does the preview of the question, but I need data from the server to update the element, hence the postback requirement. What is the best way to get this...

DisplayName attribute in List Views for ASP.NET MVC

Hi all, in my current asp.net mvc project I'm using the built in functions for displaying resourcebased text as headers for my textboxes and stuff. In Create and Edit views this is accomplished by using the HtmlHelper LabelFor method like this: Html.LabelFor(model => model.InternalTitle) BUT, the default in the asp.net mvc 2 template ...

Can you register a controller against multiple URLs in asp.net mvc?

I want to create an MVC application where by I can create areas of a site that use the same functionality but work under a seperate URL. e.g. I want to use the same image gallery controller (type not instance) under two different URLs "/Event1/Gallery" and "ProductInformation/Gallery". However if I register this in the routes table and ...

MVC 2 customErrors works locally but not live?

Here is what I have in my web.config: <customErrors mode="On" defaultRedirect="/pages/sitemap"> <error statusCode="404" redirect="/pages/sitemap" /> </customErrors> Locally this works just as expected but live for some reason I still get the vanilla 404 error page? I am using MVC 2 with Areas, throughts? ...

What is the better approach with custom error displaying in MVC 2.0

I am using ELMAH to catch and log all errors from controllers. But when errors happening i may display generic information to user using then Shared/Error.aspx will display if any error. But i have some exceptional case in my app and i need to display some custom error page with some information to user, for example i have such case: ...