asp.net-mvc-2

MVC Controller.OnException for different result types

I'm trying to find the ideal exception handling strategy for my MVC project. I have done the following and am looking for some feedback. Problem: I have disparate result types (Pages, Partial Pages, JSON, Files, etc). Controller.OnException() doesn't have an easy way to identify what kind of result the client is expecting. Without anyt...

How to save selected item from dropdownlist in asp.net mvc2

Hi simply I have an Employee class and Department class and the employee must be in a department, when I save the Employee I want to save the selected department also. any one have a code sample or any solution. ...

ASP.MVC and mvccontrib fluent test with IOC

I am trying to use the fluent test helpers to test an AbstractRestfulFluentController public class CustomerController : AbstractRestfulFluentController { private readonly IService<Customer> _customerService; private readonly IService<CustomerAddress> _addressService; public CustomerController(IService<Customer> customerServ...

MVC2 how is <%: tag different to <%=

Hi there , what is the difference between <%: and <%= ? ...

Should I use a logging framework with ASP.NET MVC 2?

I'm getting ready for my first ASP.NET MVC 2 project and was wondering whether ASP.NET Tracing is sufficient for any logging I might need to do. Is anyone using a logging framework like log4net or NLog with an ASP.NET MVC 2 application, and if so, what additional functionality does it provide that ASP.NET Tracing lacks? ...

MVC2 VS custom built framework

We are planning to start a new Sale Management System which will have about 12 subsystem. We will use MSSQL2008 as a database. We have got custom framework for ASP.NET that was built about 3 years ago which is not MVC type... And i am planning to move to MVC2 Framework. My Questions are What will be the big advantages of moving to MVC...

ASP.NET MVC2 - hook into client side validation

I want to trigger some custom code when the client side errors are updated using ASP.NET MVC2 client side validation. I've tracked down this function which I want to hook into: Sys.Mvc.FormContext.prototype = { // ... _displayError: function Sys_Mvc_FormContext$_displayError() { if (this._validationSummaryElement) { ...

Passing the value of a Textboxfor into ActionLink

Hi all, Having a little trouble and wondered if anyone could help :-) I am trying to pass the value that a user enters into a html.Textboxfor to an html.Action link. As shown below : <%=Html.TextBoxFor(m => m.OrderQty)%> <p class="button" > <%: Html.ActionLink("Add to cart", "AddToCart", ...

ASP.Net MVC UserControl in View with different controller?

Hi All, I am trying to create a usercontrol that is an extremely simple form. This usercontrol will appear in a number of different views in my app. I am thoroughly confused on how this can be accomplished. I have created a controller, and then created a usercontrol that uses that controller. I then created another controller and crea...

Is it a bad practice using model classes in controller in mvc?

Hi, I wanted to compare with best practices when working with an ORM or database tables in asp.net mvc. One of the major questions I have is should I instantiate the model classes directly in controller..not query the database but just use the model class to store the values. For e.g. If I am using entity framework as model...then is i...

How do I test an ASP.NET MVC2 post action with validation when using MvcContrib TestHelper?

I'm attempting to write a unit tests for an ASP.NET MVC 2 post action that takes a view model as its sole parameter. The view model is decorated with validation attributes such as [Required]. I'd like to test two scenarios. The first scenario is when a valid set of data is passed in (ie, all required properties have values) and a redirec...

What should I use to pass value in asp.net mvc posting form?

I am passing the edited value and retrieving it back but I dont get back the id value.. how do I get back the value for Id...The id value will actually remain the same..all I need to do is pass it back again... public ActionResult EditValue(int id) { ViewData["id"]=id; ViewData["Value"]=GetOriginalValue(); return...

Ninject V2 InRequestScope: firing constructor on every request

I'm having a hard time with Ninject V2's InRequestScope() for managing a UnitOfWork. _kernel.Bind<UnitOfWork>().To<SqlUnitOfWork>().InRequestScope(); I expect whenever I request the UnitOfWork via the container that the same object is always returned throughout the request. However, in the debugger I have a breakpoint on the object's ...

Site Navigation in ASP.NET MVC2

Hi all- I'm new to MVC and developing a basic site using the pattern. I'm trying to implement left navigation that will be consistent throughout the site... it is basically a few ul's styled with CSS and using jquery for some visual effects. I have a few questions regarding best design practices: Is it best to have the html for the ...

ASP.NET MVC (2) Data Annotation Validation and UpdateModel<T> (C#)

So, if I want to add a new object to my database, I can write this: public ActionResult Something(SomeObject Object) { if (ModelState.IsValid()) { DataContext.SomeObjects.InsertOnSubmit(Object); DataContext.SubmitChanges(); }; } But, how does validation get called when I want to update an object? Does UpdateMod...

ASP.net mvc Call Action on DropDown Value Change

Hi all, Ive got a dropdown on one of my views. This dropdown only has for entries. Basically i need to know how to call an action when the dropdown value is changed? My situation is: Im making a simple inbox page. The dropdown has the filter options: View All, View Invites, View Replies etc.. When the user selects a filter option from ...

passing paranter from asp.net to java script by JSON in html

I want o pass some JSON object in HTML response and eval it in client. I used fallowing code in server: TagBuilder tag = new TagBuilder("script"); tag.Attributes.Add("Id", id); tag.Attributes.Add("type", "text/html"); tag.SetInnerText(new JavaScriptSerializer().Serialize(content)); return...

ASP.net MVC Set Checkboxes to checked Clientside

Hi All, My situation is: Im making a simple inbox page. The inbox is a listing made from a DevExpress grid. Each row in the grid has a checkbox that the user can check so that they can multi delete records (similar to yahoo mail etc). When the user clicks the select all link or the clear all link i need to set all the checkboxes within...

Send Tweets from .net MVC

I'd like to automate the sending of Tweets from my MVC2 app. I kinda expected to see more examples and ideally a component or library i could plug into my existing app but haven't found anything yet. thx ...

visual studio 2010 debug build broken

hi, strange 1 here.. have a solution with multiple projects in (mvc2 application, class library etc). the solution will not build in debug mode anymore. 1 if the projects isnt building its DLL anymore (although it creates reference dll's in the bin\debug folder). this gives me the error: Metadata file 'C:[solution]\bin\Debug[myprojectna...