asp.net-mvc

ASP.NET MVC Master Page: "'Model' is not a member of 'System.Web.UI.Page'"

My View is strongly typed to an ADO.NET Entity Framework class with a boolean property ShowMenu. <%@ Page ... MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage(Of Thing)" %> ... I want to do something like this on my Master Page... <%@ Master ... Inherits="System.Web.Mvc.ViewMasterPage" %> ... <div id="men...

Custom IModelBinder and Database Access

For a user object in my asp.net mvc project, I have written a custom modelbinder to check whether passwords are valid and whether two matching passwords were entered etc.. The login name needs to be unique though, I was wondering whether I can check for that in the modelbinder, or is this considered bad practise ? The thing is that th...

More complex(real-life) modelbinding?

Roll with me and imagine the following example: Public ViewResult GiveMeFruit(int personId, string personName, int personAge, int fruitId){ Person person = PersonService.GetPerson(personId); person.Name = personName; person.Age = age; person.Fruits.Add(FruitService.GetFruit(fruitId)); ViewData.Person = person; Vi...

Rendering asp .net mvc partial views in Firefox

I wrote an application using ASP.NET MVC, in this application I have an Index view which renders multiple partial views. The application works fine in both IE and Google chrome but does not seem to work in Firefox. Does Firefox have any issues when rendering partial views or is there something extra that I have to add to my code? This is...

Why does MVC look for .aspx and .ascx for both full and partial views?

I've just been bitten by a problem where I have a view (FindUser.aspx) trying to render a partial view (FindUser.ascx). The default search paths for views look for a file named after the view in a variety of folders. Rather surprisingly, for views, it looks for a file with the extensions of .aspx or .ascx. And the partial views use the s...

asp.net mvc multi-parameter requests for dynamic images?

In webforms, we would do somthing like this to set up a hander to generate a dyanmic image: <img src="/barchart.aspx?width=1024&height=768&chartId=50" > Then of course we would write code on the .aspx page to render the image using the parameters and write it back into the response. I am honestly not sure how to set up/handle such a...

Hierarchical Database Driven Menu in MVC

I use the code below as an HTMLHelper which gets data from the database and loops over it to display a menu. This is fairly straightforward as you can see however, what if you have a database table using the adjacent model of heirarchies eg/ID, ParentID, OrderID. Easy to see whats going on but recursion is needed to get this data out pr...

From within a Controller's action, how can I get the current route information?

From within a Controller's action, how can I get the current route information? How can I loop through the other routes? ...

ASP.NET MVC Structural design problem

Hi, i'm new to ASP.NET MVC and i'm facing some structural design problems. I can't figure out how to setup routing. I want the following: http://website/ > HomeController Action=Index Public: http://website/{controller} > SectionController Action=Index http://website/products/id ...

MVC and XVal with drop downs - The value 'Please Select' is invalid.

Im following the approch outlined here to do this. Im having a problem with validating a dropdown selection with xval, the MVC binding seems to infer the wrong thing an allowing the operation to pass validation, but the modelstate stores the binding exception and makes the page invalid - so I get the situation where operation is allowed...

OnValidate VB.Net partial method wont fire for NerdDinner sample code

I am having a problem that gfrizzle said he had had but then said here that he fixed it.  I looked at the post and implemented what it said to do, but it still doesn’t work for me (if gfrizzle sees this, I would like to see his code) To restate the problem, I want to create business rules that are seperated from the DAL code that is gen...

AJAX and MVC (C#)

I've never used AJAX and am, quite frankly, not much versed in JS either. I have a page (Product Browser) that has the following breakdown: Navigation (First, Prev, 1, 2, 3 Next, Last) - full post back Items per Page drop down - I want to AJAX this Left Column - Filters - I want to AJAX this Product Display area - displays products ...

How to simulate Server.Transfer in ASP.NET MVC?

In ASP.NET MVC you can return a redirect ActionResult quite easily : return RedirectToAction("Index"); or return RedirectToRoute(new { controller = "home", version = Math.Random() * 10 }); This will actually give an HTTP redirect, which is normally fine. However, when using google analytics this causes big issues because the orig...

ASP.NET MVC How to specify which folder the View pages reside in?

Hi, by default the ASP.NET MVC engine searches the following folders for View pages: /Views/{Controller_Name}/{Action}.aspx /Views/Shared/{Action}.aspx However I want to put some of my View pages like this: /Views/{Namespace}/{Controller_Name}/{Action}.aspx How can I let the engine look for this? ...

CrystalReportViewer with ASP MVC

Although I have seen vague references to it here, has anyone actual managed to get the CrystalReportViewer to work with the ASP MVC framework? If so can you please give some more detailed info on how you did it. I am struggling currently. ...

AJAX Image Upload & Crop (with ASP.NET & MVC)

I am looking for a component to allow the user to upload and crop an image, resize it and save it in .PNG (or .JPG) format (if it is in a different format). What is the best solution? ...

Dynamically Choosing a Asp.Net MVC User Control

The ASP.net page I am currently working on has a drop down list that is intended to have a list of filters. When the user selects the filter, I would like to display a user control that has properties appropriate for the filter. Here is the controller action in question: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Index(FormColle...

Data entry screen in asp.net MVC

You may thick that it is a silly question but I am confused! I have a situation that I have a Lecture table. And I want to store attendance of who have registered for it. I have master table of People who will register, lecture table, and Important one table is attendance that stores P.k. as f.k. of rest of the table. On Index view o...

Best way to keep ASP.Net Session Active

Hi What is the best way to keep asp.net or asp.net mvc session active until user logs out? *User should be able to activate session even after browser or computer restarts... In another words, what is the best way to implement REMEMBER ME... ...

Creating an action link in a Controller

In one of my controller actions, I'm generating some XML. One of the attributes in that XML is an href to another controller and action, with some parameters. The XML should look something like this: <projects> <project id="42" name="Project X", href="/projects/42"/> <!-- etc. --> </projects> I don't mind if the URL is relative or...