asp.net-mvc

How would you organize this in asp.net mvc?

I have an asp.net mvc 2.0 application that contains Areas/Modules like calendar, admin, etc... There may be cases where more than one area needs to access the same Repo, so I am not sure where to put the Data Access Layers and Repositories. First Option: Should I create Data Access Layer files (Linq to SQL in my case) with their accomp...

MVC 2 Pass View to Controller to generate Excel File on-the-fly

Is there a way to pass data from a View to a Controller so that I can get the data and create a .xls file on the fly? Any help or thoughts are greatly appreciated. Greg ...

How to change id value when using Html.DropDownListFor helper in asp.net mvc 2.0?

Hi I have a partial view that has something like this <%= Html.DropDownListFor(m => m.SelectedProductName, Model.ProductList, "Select a Product") %> Now you can create a new product and edit a existing product. Both editing and creating use the same form. The create is on the main page on load up. Edit popus up in a jquery u.i model...

How to give user confirmation message before ActionLink based on validation

I have the following link. On click, I'd like to check the item.primary_company field and if populated, give the user a warning and ask if they would like to continue. How can I do this? <a href="<%= Url.Action("Activate", new {id = item.company_id}) %>" class="fg=button fg-button-icon-solo ui-state-default ui-corner-all"><span class=...

Is ASP.net MVC a direct copy of Ruby on Rails concepts?

Hi, I'm been developing Ruby on Rails previously. I'm now looking at an ASP.net web app and I'm looking at WebForms and MVC. As I look at MVC it feels as if I'm looking at the result of something a Ruby on Rails developer implemented after being forced to work in MS land. So I'm wondering: Was MVC more or less taken directly from Ru...

asp.net mvc select list

ok what i want to do is to using forcollection["Selectlist"] only selected things in the select list will be availabe when the form posted i am using add ,remove mechanism in my listbox , so i want to make everything that is there in the checkbox as available to the forcollection["Selectlist"]. can it be done? ...

DI: Injecting ActionFilterAttribute implementation (ASP.NET MVC)

I was wondering if it is possible to inject a particular ActionFilterAttribute implementation using a IoC container. For example, imagine you create a TransactionAttribute class [Transaction] You use this to decorate action which should be wrapped in a transaction in the persistence layer. But implementation details of the attribute w...

asp.net mvc controller actions testing

I was just wondering how others are going about testing controller actions in asp.net mvc? Most of my dependencies are injected in to my controllers so there is a not a huge amount of logic in the action methods but there may be some conditional logic for example which I think is unavoidable. In the past I have written tests for these a...

ASP.NET MVC question

I want the following structure in my ASP.NET MVC solution; Controllers/HomeController.cs Controllers/Administration/AdministrationController.cs Controllers/Administration/UsersController.cs Views/Home/Index.aspx Views/Administration/Index.aspx Views/Administration/Users/Index.aspx Views/Administration/Users/AddUser.aspx etc. How can...

How do I use master page container in partial view

I have several partial views with Javascript that I am trying to move to the bottom of the page. To do this I am trying to use a container in the master page Master Page -> <asp:ContentPlaceHolder ID="Foot" runat="server"></asp:ContentPlaceHolder> Partial view(ascx) <asp:Content ID="header" ContentPlaceHolderID="head" runat="se...

ASP.NET MVC DataViewModel Problem no insert and edit

using the code DataViewModel with one form for create and edit with partial view , in the code below In the create*I am not able to enter the values to the database*,In the edit Mode I am not able to display the value as well in the textboxes for edit(The record is created but no form value is going to the database). public class Orga...

ASP.NET MVC Create dynamic navigation sub-menu on the master page

I'm trying to create an ASP.NET MVC master page so the site navigation on it will look like this: Main Menu:Home | About | News Sub Menu: Home_Page1 | Home_Page2 The Sub Menu section should always show sub-menu for the currently selected Main Menu page (on the example above 'Home' page is selected) unless a user hovers the mouse o...

MVC: How do i declare the name value using DropDownListFor

I have the following dropdownlist in mvc <%= Html.DropDownListFor(c => c.Address.Id, new SelectList(Model.Addresses, "id", "Name", Model.Address.Id), "-- New Address --", new { @name = "[" + orderItemAddressCount + "].AddressId" })%> I'm trying to overwrite the name value on the dropdownlist. this is the markup i get <select id="...

Problem with Models on Master Page View.

Have a problem with master page views and models. In the first image, I have a simple view in which I am trying to access the Model properties. None of the model properties are available at this time (this is the problem). If I use a <%= Model.blah %> then you can see that the model properties are available. Second photo. In the last ...

How Does One Differentiate Between Routes POSTed To In Asp.Net MVC?

I have two actions, one that accepts a ViewModel and one that accepts two parameters a string and an int, when I try to post to the action, it gives me an error telling me that the current request is ambiguous between the two actions. Is it possible to indicate to the routing system which action is the relevant one, and if it is how is ...

How to build C# object from a FormCollection with complex keys

i have a javascript object, obj, that gets passed to an mvc action via a $.post() like so: var obj = { Items: [{ Text: "", Value: { Property1: "", Property2: "" }, { Text: "", Value: { Property1: "", Property2: "" }] }; $.post('MyAction', obj, function() {}); the action signature looks like this: public ActionResult M...

App_GlobalResources broken in ASP.NET MVC 2 and VS 2010?

Good day! I have installed VS 2010 Express and resource files in App_GlobalResources are not compiled into strongly typed Resources class. More specifically no more code generation take place. I have tested with my MVC project (updated from MVC 1.0 and VS2008) and with blank ASP.NET MVC 2.0 project generated by VS and got error (even ...

ASP.NET MVC How to convert ModelState errors to json

How do you get a list of all ModelState error messages? I found this code to get all the keys: ( http://stackoverflow.com/questions/888521/returning-a-list-of-keys-with-modelstate-errors) var errorKeys = (from item in ModelState where item.Value.Errors.Any() select item.Key).ToList(); But how would I get the error me...

MVC session state can i disable in IIS?

In IIS setting may I disable Session state without issue? ...

Escape apostrophe when passing parameter in onclick event

I'm passing the company name to an onclick event. Some company names have apostrophes in them. I added '.Replace("'", "'")' to the company_name field. This allows the onclick event to fire, but the confirm message displays as "Jane&# 39;s Welding Company". <a href="#" onclick="return Actionclick('<%= Url.Action("Activate", new {id ...