asp.net-mvc

LINQ to SQL - How to efficiently do either an AND or an OR search for multiple criteria

I have an ASP.NET MVC site (which uses Linq To Sql for the ORM) and a situation where a client wants a search facility against a bespoke database whereby they can choose to either do an 'AND' search (all criteria match) or an 'OR' search (any criteria match). The query is quite complex and long and I want to know if there is a simple way...

ASP.NET MVC 2 RC2 Routing - How to clear low-level values when using ActionLink to refer to a higher level?

[NOTE: I'm using ASP.NET MVC2 RC2.] I have URLs like this: /customers/123/orders/456/items/index /customers/123/orders/456/items/789/edit My routing table lists the most-specific routes first, so I've got: // customers/123/orders/456/items/789/edit routes.MapRoute( "item", // Route name "customers/{customerId}/orders...

JavaScript on jQuery created code never gets called

This is my view in ASP.NET MVC. <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Administration.Master" Inherits="System.Web.Mvc.ViewPage" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server"> <script type...

asp.net mvc pass a variable to another action method with a form post

Hi, I have a page. (action) and a controller called Widget. im passing in client as a string. I want to be able to pass in the client from one page to the next, as well as the other fields posted. what am i doing wrong below? client is coming up as null eg: Widet/Page2/clientABC public ActionResult Page2(string client) ...

MVC 2 Ajax.Beginform passes returned Html + Json to javascript function

Hi, I have a small partial Create Person form in a page above a table of results. I want to be able to post the form to the server, which I can do no problem with ajax.Beginform. <% using (Ajax.BeginForm("Create", new AjaxOptions { OnComplete = "ProcessResponse" })) {%> <fieldset> <legend>Fields</legend...

ASP.NET MVC 2 DropDownList not rendering

Hi, so I don't understand what I am doing wrong here. I want to populate a DropDownList inside the master page of my ASP.NET MVC 2 app. Projects.Master <div id="supaDiv" class="mainNav"> <% Html.DropDownList("navigationList"); %> </div> MasterController.cs namespace ProjectsPageMVC.Controllers.Abstracts { public abstract class ...

Changing values of (multiple) dropdown lists from one dropdown list in MVC

I have an MVC page, with some controls inside a form. The part I need help with: I have a bunch of dropdowns in a list. All dynamically named (drop{0}, where {0} is the id (really, its just a counter: 1,2,3,etc)). At the top of the list, I want to have another dropdown that will update ALL the dropdowns when it is changed. I've done sim...

Ninject woes... 404 error problems

We are using the beloved Ninject+Ninject.Web.Mvc with MVC 2 and are running into some problems. Specifically dealing with 404 errors. We have a logging service that logs 500 errors and records them. Everything is chugging along just perfectly except for when we attempt to enter a non-existent controller. Instead of getting the desire...

Does MVC.NET handle roles through cookies?

Does MVC.NET handle Roles using cookies, or does a controller check with the Role Provider on each request? Consider this code: [Authorize(Roles="CommentsModerator, SiteAdministrator")] public ViewResult ApproveComment(int commentId) { // Implement me } Are roles set as a cookie when a user first lots on, or will the Authorize at...

ASP.NET MVC ajax - data transfer

How can I get result from action? I need to show the commentID on the page (aspx) after successes comment insert. controller [AcceptVerbs(HttpVerbs.Post )] public ActionResult ShowArticleByAjax(Guid id, string commentBody) { Guid commentID = Comment.InsertComment(id, commentBody); //How can I t...

How do I retrieve row ID from an MVCContrib HTML Grid?

Hi, I currently have a product view page that contains an MVCContrib HTML Grid with a select link at the beginning of each row. If the select link is clicked, it takes me to a different page. My question is whether it is possible to retrieve the productID from the row that is selected and pass that to the next page. Maybe this is pos...

Where to use Controller.HttpContext

Hi, In my base controller's constructor I am calling an extension method that checks for specific cookies on the client. Currently I am using System.Web.HttpContext.Current to get the current context. However, I am lead to believe that I should be using Controller.HttpContext since it is more testable and contains additional informati...

Architecting ASP.net MVC App to use repositories and services

Hello, I recently started reading about ASP.net MVC and after getting excited about the concept, i started to migrate all my webform project to MVC but i am having a hard time keeping my controller skinny even after following all the good advices out there (or maybe i just don't get it ... ). The website i deal with has Articles, Videos,...

Javascript callback not firing when AJAX operation complete

Given the following code on an ASP.NET MVC View: <% using (Ajax.BeginForm("AddCommunity", new AjaxOptions { UpdateTargetId = "community-list", OnSuccess = "BindCommunityHover" })) { %> Add Community: <input type="text" id="communityName" name="communityName" /> <input type="submit" value="Add" /> <% } %> And the ...

ASP.NET MVC Model Binding

If i have a Controller Action that may recieve both HTTP GET and HTTP POST from a number of different sources with each source sending different data e.g. Source1 performs a form POST with two form items Item1 and Item2 Source2 performs a GET where the data is contained in the query string (?ItemX=2&ItemY=3) Is it possible to have a ...

HTML Button calling a MVC Controller and Action Method

I know this isn't right but for the sake of illustration I'd like to do something like this: <%= Html.Button("Action", "Controller") %> My goal is to make an HTML button that will call my MVC controler's action method. Thank you, Aaron ...

ASP.NET MVC Custom Role Provider/RolePrincipal

My asp.net MVC application is not caching roles instead it round tripping to the database every request. Also when I attempted to view the cookie I noticed it had not been written to the browser. Web.config: <roleManager defaultProvider="CustomRole" enabled="true" cacheRolesInCookie="true" cookiePath="/" cookieName="CustomRole" maxCach...

Ajaxing a link in a table

I have a table of results in an ASP.Net MVC page where the last column is an View Details link. I want to have the user click the View Details link and an AJAX method be called to open the results in floating dialog. What I am struggling with is how to link the AJAX call to the link in the results table. I was using a link which embedde...

How to create a MVC 2 DisplayTemplate for a field whose display format is dependent on another field?

If I have a property whose display format is dependent on the value of another property in the view model how do I create a display template for it? The combination of field1's display being dependent on field2's value will be used throughout the app and I would like to encapsulate this in a MVC 2 display template. To be more specific...

How to redirect [Authorize] to loginUrl only when Roles are not used?

I'd like [Authorize] to redirect to loginUrl unless I'm also using a role, such as [Authorize (Roles="Admin")]. In that case, I want to simply display a page saying the user isn't authorized. What should I do? ...