asp.net-mvc-2

Why is my C# template method complaining about accepting a specific type?

Hello. I'm diving into ASP.NET MVC 2 and I'm walking through a tutorial and I'm getting an error related to a template method in my unit tests. The erroneous code is... var displayedProducts = (IList<Product>)result.ViewData.Model; displayedProducts.Count.ShouldEqual(2); and the method definition for ShouldEqual is... public static...

Use a System.Data.Linq.Binary object as an HTML image source

I'm using ASP.NET MVC and have a model that has System.Data.Linq.Binary property. The property represents a picture that has been stored in the database as an image column. I am able to use the picture in my pages by setting up a separate controller action and using Response.OutputStream.Write to dump the Binary object and then setting...

MVC2 C# - Why I cannot asign a Model.ImageUrl to a img src attribute in a UserControl?

I'm starting with MVC 2 in Visual Studio 2010. The thing is I'm working with a MasterPage where I'm rendering an action which returns a UserControl: Everything works well, I mean the user control has a lot of other labels and it's rendering other properties... So the problem has nothing to do with anything apart the img tag and the src a...

T4MVC in MonoDevelop 2.4

Hello! Has anyone tried to make T4MVC work in MonoDevelop? Out of the box, I get this error: Could not resolve include file 'T4MVC.settings.t4'. When I include the full path in the include statement, it makes MonoDevelop crash completely. Thanks for any info! Marc Lacoursiere ...

ASP.NET MVC 2 Confused about Javascript

Hi I'm building my first MVC 2 app and I'm really confused by all the examples I'm reading. I am also using the Telerik MVC kit for their Grid, and other such controls. I've read many tutorials and watched videos but I can't quite grasp the pattern of where to place javascript and how to wrap blocks of code in the appropriate tags. For ...

Add per request, token based authentication to asp.net mvc site

I have an existing asp.net mvc website that uses basic forms authentication. The site has a login page that posts back to a login action, which logs the user in via FormsAuthentication.SetAuthCookie(). I am looking to add an api to the site, as an mvc2 area, where users would be authenticated based on a token passed as an http header. ...

ASP.NET MVC 2 routing problems with string

I want to add a simple route to my webapp, but it just doesn't work and i don't know why code in global.asax.cs: routes.MapRoute( "BrowseGenre", "{controller}/{action}/{genre}", new {controller = "Store", action = "Browse", genre = UrlParameter.Optional} ); code in StoreController.cs: ...

get value from custom attribute in editor template

at the moment I have this: in the ViewModel: [MyCustom(Foo = 23)] public int CountryId { get; set; } in the Editor template: <%= Html.TextBox("", Model) %> how can I get the value (Foo=23) from my custom attribute (MyCustom) into the editor template ? ...

View strongly typed to View model not returning Model back to controller on postback

I have a PartialView strongly typed to a view model <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<VATRateManager_MVC.Models.ViewModels.RateControlEditViewModel>" %> <script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script> <script src="../../Scripts/MicrosoftMvcValidation.js" type="text/javascri...

how can i change the View Data data from j query and assign it to control ?

Hi I am getting data in ViewData on my view in my asp.net MVC application. I want to change the value of control dynamically. so I have write the Jquery for this. But How to get data from ViewData and and update it dynamically? how can i change the View Data data from j query and assign it to control ? ...

how to access the Model Classes in J query ?

how to access the Model Classes in Jquery in asp.net mvc ? ...

Validation in ASP.NET MVC 2

Hi, I have some problems with validation using Data Annotations in ASP.NET MVC 2. For example, I have Address class: public class Address { public long Id { get; set; } [Required] public string City { get; set; } [Required] public string PostalCode { get; set; } [Required] public string Street { get; set;...

ASP.NET MVC Html.DropDownList populated by Ajax call to controller?

I wanted to create an editor template for a field type that is represented as a dropdownlist. In the definition of the editor template I would like to populate the DropDownList using a call to an action on the controller returning the results as JSON - Any ideas how to do this? E.g something like: <%@ Control Language="C#" Inherits="S...

What are some tips for a high traffic, complex form in ASP.NET MVC?

We currently have a WinForms application that we want to slowly migrate to a web application. One screen is a time sheet entry system that uses DataWindow and is very slow and buggy. Anyway, the time sheet screen has five sections that are saved in real time. A finished time sheet needs 2-5 of these sections. Currently, the system run...

When I add FormsAuthentication to ASP.NET MVC2 site in IIS7.5 I get HTTP 403.14 error

I have written a custom forms authentication module and when I add it to the web.config of my MVC2 application and run under IIS7.5 I get the HTTP 403.14 error. If I try to navigate to any of the routed Urls then I simply get a 404 error. The annoying thing is that I did all the testing using Cassini with no problems at all. I have appli...

MVC. Itextsharp write pdf to response

I am generating pdf using itexsharp. I am creating MemoryStream, then when i am trying t write MemoryStream bytes in to response but no luck. When i am executing this code in my controller the pdf not coming in response. Memory stream is populaitng correctly i can see this in debugger, but for some reason this number of butes not comin...

Output text with hyperlinks

If you have text coming from a database such as: "New Apple TV Offers 8 GB of Internal Storage, 256 MB RAM http://t.co/fQ7rquF" Is there a helper method that takes that text and wraps the web address as a anchor tag? ...

Generic TimeSpan binding in Asp.NET MVC 2

I have an input form that is bound to a model. The model has a TimeSpan property, but it only gets the value correctly if I enter the time as hh:mm or hh:mm:ss. What I want is for it to capture the value even if it's written as hhmm or hh.mm or hh.mm.ss or ... I want many different formats to be parsed correctly. Is this possible? Thank...

ASP.NET MVC sitemap for a traditional hierarchical site

I have tried to use http://mvcsitemap.codeplex.com/ but i can't get it to work with an hierarchical structure from the database... with that said, does anyone know of any other site map provider or can use? ...

Execute/Query against SQL Compact 4.0 in ASP.NET

I'm writing a small little utility MVC app and I need to have the ability to execute ad-hoc queries against my one-table SQL Compact 4.0 .sdf file for management (Web Matrix isn't working right for development, and it won't be available on the PC this will ultimately be running on). Using Entity Framework code-first, everything is worki...