asp.net-mvc

ASP.Net MVC - Showing Model data based on Roles

Hi, I have a View which needs to show and hide details based on the users role. I have 2 options using an inline if statement in the View to show and hide details Create multiple partial views and use to controller to detect the role and then load the appropriate Partial view. Im a newbie to MVC so can someone please advise what the...

POCO objects with lazy loading

Hi! I'am new to ASP.NET MVC, IoC, POCO, etc. So I want to know is it OK to use such kind of architecture. This is my demo project. Project.Core (this assembly referenced by all project) public class User { public string Name {get; set;} public List<UserGroup> UserGroups{get; set} } public class UserGroup { public string Tit...

Problem with DataAnnotationsModelBinder in ASP.NET MVC 2

Everybody tried out a tutorial on DataAnnotations from mvc official website? It didn't work for me. When I'm trying to submit edited product, I have this error message: Method not found: 'System.Collections.Generic.IDictionary`2 System.Web.Mvc.ModelBindingContext.get_ValueProvider()'. I'm using ASP.NET MVC 2 preview 2. Any ideas why this...

How to configure url routing if I have duplicate controllers or views

Hello folks, I am a newbie of the ASP.NET MVC framework I am just wondering how to configure in my case. I'd like to make a url in my mvc application as following : 1) http://localhost/statistics/people/index 2) http://localhost/statistics/animal/index 3) http://localhost/information/people/index 4) http://localhost/information/ani...

The string was not identified as a valid Boolean string.

Hello I have a page where I list checkboxes named TimeRange1, TimeRange2.... TimeRange7, and I generate them in a for loop like this: <% for (int currentDay = 1; currentDay <= 7; currentDay++) ......<%= Html.CheckBox("TimeRange" + currentDay.ToString(), false)%> Works fine til I post the form, then I get a "The string was not identif...

View Models Asp.Net MVC

When using MVC and converting your data into ViewModels which is the accepted way to do this? At the moment I'm using AutoMapper to do this and its working well. However I did see in a blog article (I think it was Rob C) having a constructor on the ViewModel which takes the number of required params and then generates the ViewModel Eg ...

Display other fields besides just the foreign key Id in a list using Linq to sql

hello, What is the best way to display the username instead of the Author_Id (foreign Key) when I display a list of records. I am using Linq to Sql on this project. <% foreach (var item in Model) { %> <tr> <td> <%= Html.Encode(item.Title) %> </td> <td> <%= Html.Encode(item.Author_Id) %> <% } %> ...

Event Calendar in MVC

Hello All, I want to fulfill this functionality: Calendar by month pops up with event names written on the calendar Access a daily event summary by clicking a day in the calendar Please tell me from where shall I start Thanks Ritz ...

ASP.NET MVC debugging following VS2010 uninstall

OK this is an odd one. I wanted to install ASP.NET MVC 2 Beta 2, so I uninstalled VS2010 Beta 2 (which I wasn't using anyway) and installed MVC 2. I then upgraded one of my projects to MVC 2 but noticed that if I try to set a breakpoint on any of my view models (classes in the Models folder) I get an error message about debug symbols. ...

Asynchronous generation of PDF - error handling

We have some code that uses a third party component to generate a PDF from a URL that we pass it (the URL being a page within our application). In the code, we instantiate the PDF generator and it creates the PDF in an asynchronous fashion. The problem I have is that if the URL that we pass it has a problem, there is no indication of t...

Page generation time - ASP.Net MVC

I'm looking for a way to track how long it took for a page to be generated by the server. I know I can use Trace to track this but I need a way to display this per page. Its ASP.Net MVC 2 ...

transform pressed key values to english values

Hi, I have an input like this <input id="guestCard" name="guestCard" onkeypress="transform(event)" type="text" value="" /> and I want to transform the key pressed on a keyboard regardless of which language settings to english character. E.g. when I press on czech keyboard + (with keycode 43) , I want to get 1 (with keycode 49). Is the...

JQGrid URL Sometimes including controller in call

So I have this code in a javascript function in my ASP.NET MVC application... jQuery("#SomeResultsGrid").jqGrid({ url: 'SomeSearch.mvc/SomeSearchResultsGridEventHandler', ... This loads on my default page and raises just fine (fiddler confirmed). Now, if I go to that default page (via a Html.ActionLink), the url that posts...

Working with State Machine Workflows in ASP.NET MVC

I have a state machine workflow which contains a number of states. Each state has an event driven activity that handles an external event. When that event fires, I'd like to either redirect the request to a different Controller Action or a View. What is the best way to redirect to a different view or controller action when an event is...

organizing admin related controllers and viewpages

admin section is at www.example.com/admin so I have an admincontroller. But I also have user admin related controllers, and configuration controllers, I want the url to be like: www.example.com/admin -> adminController www.example.com/admin/user/ -> adminUserController www.example.com/admin/user/edit www.example.com/admin/user/add ...

jquery - dynamically fill fields with json based on property name

asp.net mvc model object is being fetched by ajax call - $.ajax(.... form has fields with IDs exactly to matching properties on returned json object (created by Html.TextBox("NAME", Model.Order.NAME) ) How to automatically populate fields(inputs) with corresponding json object properties ? Manually would be like $("#NAME).val(json.NAM...

InvalidOperationException and Workflows in ASP.NET MVC

I'm trying to query a running state machine workflow using StateMachineWrokflowInstance in ASP.NET MVC. Here is the scenario: Workflow runtime configuration: added SqlWorkflowPersistenceService, ManualWorkflowSchedulerService, ExternalDataExchangeService and registered custom ExternalDataExchange service with ExternalDataExchangeServi...

xVal and Validating multiple rows of data

I have a table name Discount that has the following schema: PK DiscountID int FK CustomerID int Amount money Name varchar(50) So I am displaying all the discounts related to the customer. Each customer will have 3 discount records. When I generate the form the ID's and Name's of the associated textboxes for editing that have to be ...

Some unit tests failed when migrating project from asp.net mvc 1.0 to asp.net mvc 2 beta

When I migrated sample SportsStore app from Steve Sanderson's Pro ASP.NET MVC Framework (from asp.net 1.0 to mvc 2 beta) using this app provided by eric lipton, everything work just fine - except 2 unit tests. The error message on both is: Tests.CartControllerTests.VeryLongTestMethodName: System.ArgumentNullException: value can't be unde...

Can a partial view be used to do Ajax item updates?

I have a table built from a list of defect codes. Can part of each row load a sub-table item complete with submit buttons? Sample table: <table><tr> <th>Code</th><th>Description</th> <th>Impact to your customers</th> <th>Impact to your associates</th> <th>Save</th> <th>Save Errors</th></tr> Where the first 2 columns are populated f...