asp.net-mvc-2

How to change width of html.DropDownListFor()

I have small design question about html.DropDownListFor() How can i change width of html.DropDownListFor() ?? For example by css. Thanks for answers ...

Use the repository pattern when using PLINQO generated data?

I'm "upgrading" an MVC app. Previously, the DAL was a part of the Model, as a series of repositories (based on the entity name) using standard LINQ to SQL queries. Now, it's a separate project and is generated using PLINQO. Since PLINQO generates query extensions based on the properties of the entity, I started using them directly in my...

Can't get NUnit to work in Visual Web Develper 2010 express.

First off I was wondering whether it's possible to implement a functionality with Nunit where each time a project is created in Visual Web Developer 2010 I get a dialog asking whether I want to create a unit test project for current application like I saw it happen in the older versions of Visual Web Developer. I've tried just about eve...

asp.net mvc select change redirect to Action

I am correctly passing the action name from the Controller to the paging class and then using select list i want to redirect to that action. at this moment it is appending to the current url.i want the correct way of redirecting to the controller action manageUser using select list below What should we have here in Model.COntroller . ...

asp.net mvc Records Based On other

I want to create a listing view in which the record will be in this format(basically one record based on other, what approach i should follow) . My table Module1 Module1Feature Module1Feaure2 Module1Feature3 Module2 Module2Feature Module2Feature2 Module2Feature3 Basically Please Notice that the child records are based on the parent. ...

How can a formcollection be enumerated in ASP.NET MVC2

I was previously using http://stackoverflow.com/questions/762825/how-can-a-formcollection-be-enumerated-in-asp-net-mvc 's implementation but now I'm on VS2010 and MVC2 its complaining: Error 1 Cannot implicitly convert type 'System.Web.Mvc.IValueProvider' to 'System.Collections.Generic.IDictionary'. An explicit conversion exists...

How to enable favorite song feature with ajax in ASP.NET MVC2?

Say, we have a list of songs we want to display. If the user is logged in, he can favorite a song in a list of songs. We want to accomplish this using ajax. So we have the usual Song repository up, from where we fetch (paginated) songs and push them to view. In the view, we have something like <% foreach (Song song in Model) { %> .....

ASP.NET MVC 2 - user defined database connection.

Hello, I am looking to port my very basic DBMS software from classic ASP to ASP.net - however the user would need to input the connection details in order to connect to their specific DBMS server. Is this at all possible with ASP.NET MVC (very similar to DSN-less connections in ASP). Cheers, Joel ...

DataAnnotationModel ASP.Net

When I 'm using the DataAnnotationModel for form validation with a List datastructure in the model, I get a NullReferenceException on form submit. How do handle the situation. My model contains public class GroupModel:ModelBase { [Required(ErrorMessage = "Primary Group Name required")] public string PrimaryGroupName...

ASP.Net MVC 2 - How to set up a Cancel button with client side navigation

Thanks to a previous question I found a useful link on multiple buttons. http://weblogs.asp.net/dfindley/archive/2009/05/31/asp-net-mvc-multiple-buttons-in-the-same-form.aspx What I want to do is have a cancel button on my page, similar to this; <button name="button" type="button" onclick="document.location.href=$('#cancelUr...

MVC 2, Custom ModelBinder, and storing the "attempted value" for the view

I have an object that was previously round-tripping from the server to the client and back nicely (i.e. edit and view forms worked fine). However, I've added to that object a complex type and made a custom ModelBinder to handle it. The complex type can be represented as a single string but is stored in the object as a Decimal (think "0...

ASP.MVC 2 Model Data Persistance

I'm and MVC1 programmer, new to the MVC2. The data will not persist to the database in an edit scenario. Create works fine. Controller: // // POST: /Attendee/Edit/5 [Authorize(Roles = "Admin")] [AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(Attendee attendee) { if (ModelState.IsValid) ...

Quick question. Html.ActionLink and creating Internal Links ( #home, #about, etc. )

Hi there, quick question... How can I best create internal links? This is the markup I want to achieve: <h3>Title</h3> <ul> <li><a href="#prod1">Product 1</li> <li><a href="#prod2">Product 2</li> <li><a href="#prod3">Product 3</li> ... <li><a href="#prod100">Product 100</li> </ul> <div id="prod1"> <!-- content here --> </d...

How to write a simple Html.DropDownListFor()?

I'm new in ASP.NET MVC 2 and I'd like to write a very simple dropdown list which gives static options. For example I'd like to provide choices between "Red", "Blue", and "Green". ...

How do I reference members of a single object passed to the View?

I'm new to MVC2 in ASP.NET/C#, so please forgive me if I misunderstand something. I have code similar to this in my Controller: var singleInstance = new Person("John"); ViewData["myInstance"] = singleInstance; return View(); So in my view, Index.aspx, I want to be able to reference members in that object. For example, Person has a mem...

How to display a generic error page in Asp.Net MVC 2

I have the following in my base controller: protected override void OnException(ExceptionContext filterContext) { if (filterContext == null) { throw new ArgumentNullException("filterContext"); } // If custom errors are disabled, we need to let the normal ASP.NET exception handler ...

Validation without UpdateModel

I have a an ASP.NET MVC2 application, with Linq2SQL, that updates a database without using the UpdateModel. Is it still possible to trigger validation without using UpdateModel? ...

How to convert model into url properly in asp.net MVC?

From the SEO standpoint it is nice to see urls in format which explains what is located on a page Let's have a look on such situation (it is just example) We need to display page about some product and decided to have such url template for that page: /product/{ProductId}/{ProductCategory}/{ProductUrlName}. And create for this purpose su...

Form with list of checkboxes (best practices)

I have a view that allows the user to make a selection from an IEnumerable. The way I'm doing it now is to give each checkbox the id of the item and work with the form collection at the controller's side. I seem to remember there to be a better way but can't remember how anymore. Are there any better practices? ...

How to call a Web Service from the Controller?

I have an asp.net MVC2 application that needs to call a web service from the controller. How do I do this? It is a RESTful service that returns Json data. I cant seem to find a good example. Thanks ...