mvc

Dynamically set the option values

I have 2 different lists: EmployeeNames and Names I read the values in Names and that of EmployeeNames. If EmployeeNames exists in Names, I must not add that value to "ToSelectBox" but to "FromSelectBox". If EmployeeNames doesn`t exist in Names, I must add that value to "ToSelectBox" but not to "FromSelectBox". How can I do that dynam...

MVC - Sanitizing data, where?

I'm using CakePHP but it's a question about the MVC pattern. I have in my form the input-text for the tags (separated by commas). To add the tags I've created a Tag model method that basically check if the tag exists and then add the new tag or just a new unit in the tag counter (the Tag model has these fields: id, name, slug, count). In...

Implement System.Web.Caching.Cache Object in a controller to cache specific query

Is it correct to implement my caching object like this in my controller : public class HomeController : BaseController { public static Cache cachingControl = new Cache(); ... And I Use it like this : public ActionResult Home() { IndexViewData view = new IndexViewData(); view.UserId = UserId; if (cachingControl.Get("view...

Calculating monthly reports or statistics - MVC Entity Framework LinQ

Hi I am using MVC (C#) and the Entity Framework. I have a sql server database with tables called Profile, Gallery, ArtWork : PROFILE: UserName, FirstName, etc... GALLERY: GalleryID, UserName, GalleryName, ARTWORK: ImageGuid, GalleryID, Description, PublishDate, Views, Downloads, I have the following relationship between the tables: ...

Whats the best way of using MVC + ajax (jquery) to load page content, aspx or ascx or both

I want to have a menu that when I click replaces the content of a "main" div with content from a mvc view. This works just fine if I use a .aspx page, but any master.page content is then doubled (like the and any css/js). If I do the same but uses a .ascx user control the content is loaded without the extras, but if any browser loads th...

How do you manipulate form values based off local input?

I have a form that has a series of check boxes and some line items have a text input next to them that defines quantity of the item. <input type="checkbox" name="measure[][input]" value="<?=$item->id?>"> <input class="item_mult" type="text" name="measure[][input]" /> What is the best way to capture the integer from the input field a...

How do I create a loop based off this array?

I'm trying to process this array, first testing for the presence of a check, then extrapolating the data from quantity to return a valid price. Here's the input for fixed amounts of items, with no variable quantity. <input type="checkbox" name="measure[<?=$item->id?>][checked]" value="<?=$item->id?>"> <input type="hidden" name="measure...

Mapping route & parameters in ASP.NET MVC

In Area VIPUsers I have controller ProfileController and other controllers. If I want every method in ProfileController to have parameter (id) and every method in other controllers to have parameter (userid and id) how would I map it? Would it be context.MapRoute("ProfileMapping", "VIPUsers/Profile/{action}/{id}", new {controller="M...

Adding bindingRedirect element in web.config when upgrading from asp.net mvc 1 to asp.net mvc 2

Hi all, I have got a question with regards to upgrading asp.net mvc applications from v1 to v2... I've noticed in the ASP.NET MVC v2 Release notes that we need to add this code (please see below) when upgrading, but it did not state what would be the purpose of it because I've tried experimenting some of my apps to asp.net mvc 2 withou...

Postback problem? Not getting data back from DB

I'm not getting back data from my DB like I'm expecting. I know that I can get data from the DB because I have other functions working. With this page, what I'm trying to do is the following: If no postback, then I would like it to echo "No Category Selected" If a category has been chosen, then I would like for it to get that data from...

Can I use Expression Web 3 to design ASP.NET MVC views?

I want a visual tool to build the html for my ASP.NET MVC views, and Expression Web 3 is on sale. Alternative would be Dreamweaver. But I have not used either tool so I don't know if they 'play well' with MVC. I basically want a tool to design a clean, professional looking web front end without having to type up all the HTML by hand i...

Help organising controllers logically

Hi guys, I'm working on a site which i'm developing using an MVC structure. My models will represent all of data in the site, but i'm struggling a bit to decide on a good controller structure. The site will allow users to login/register and see personal data on a number of pages, but also still have access to public pages, e.g FAQs, Co...

How should I pass the translated text to my object in my multilingual application?

Up until now, I have maintained a 'dictionary' table in my database, for example: +-----------+---------------------------------------+-----------------------------------------------+--------+ | phrase | en | fr | etc... | +-----------+---------------------...

Custom Views in MVS with input names not-matching to Model property names.

We are using MVC in our application; the Views we are using get created by other team. The problem is that they use their own names for input HTML controls which are different from the input text-box names in the Model. I have a strong feeling that this issue had already been addressed somewhere but cannot find any references. Could anyb...

HTML Button's jQuery function is having trouble with MVC FileResult

I intended for this function to call my MVC action method that returns a CSV report. $(function() { $('#exportButton').click(function() { $.get('/curReport/GetCSVReport'); }); }); If I make a button like the code below then, when it is clicked, I'm given the "Open with/Save File" window. <input type="button" value="Ex...

When using Data Annotations with MVC, Pro and Cons of using an interface vs. a MetadataType

If you read this article on Validation with the Data Annotation Validators, it shows that you can use the MetadataType attribute to add validation attributes to properties on partial classes. You use this when working with ORMs like LINQ to SQL, Entity Framework, or Subsonic. Then you can use the "automagic" client and server side vali...

Using ASP .NET Membership and Profile with MVC, how can I create a user and set it to HttpContext.Current.User?

I implemented a custom Profile object in code as described by Joel here: http://stackoverflow.com/questions/426609/asp-net-membership-how-to-assign-profile-values I can't get it to work when I'm creating a new user, however. When I do this: Membership.CreateUser(userName, password); Roles.AddUserToRole(userName, "MyRole"); the user...

Best place to check user authenticity in a back end module where all pages are only available to members?

I've a backend module which could only be accessed by authorized members. So I need to check authenticity for all actions and for all controllers. Currently I'm doing it inside preDispatch() functions inside controller classes. So it takes care of all the actions inside that controller. But still I've to do it for all controllers. Is the...

Search Route in ASP.NET MVC

Hi. I have a simple search form in my master page and a serach controller and view. I'm trying to get the following route for the string search term "myterm" (for example): root/search/myterm The form in the master page : <% using (Html.BeginForm("SearchResults", "Search", FormMethod.Post, new { id = "search_form" })) ...

Close tag on closing brace using Html Helper in ASP.net MVC

Hi, How can I create a helper like the Html.Form helper, which closes the tag when you close the braces? ...