asp.net-mvc

Return False Never Works For me With Jquery Submit? What am I doing wrong?

Hi I am trying to stop my form from submitting yet I never can get it work and always end up changing it to a button type. However I want to see if I keep the submit button as is if I can have in my Asp.net mvc application as a FormCollection Paramater. Yet I can't even try really passing in anything until I get it to stop submitting....

ASP.NET MVC + LINQ exception

Hi, I've got a ASP.NET MVC application that works great for 99.9% of the time. Once in a blue moon though things go really bad and I was wondering if anybody could shed some light on what might go wrong here. The web application is using Linq2SQL and blows up in a controller after the following set of instructions: const ...

How to unit test IDataErrorInfo?

Hi I am reading Asp.net MVC Framework and I am reading about IDataErrorInfo as form of validation. So I am just going to post what he has. Product Class using System; using System.Collections.Generic; using System.ComponentModel; namespace MvcApplication1.Models { public partial class Product : IDataErrorInfo { priv...

Question about binding in asp.net mvc?

Hi How does binding work? Like how many fields have to match up to make a successful bind. Say you got a Product class with 5 fields and only 4 of the fields match up does it still bind? Also I know they have an exclude for binding but how do you do multiple excludes? Like if I have 2 fields I want to exclude how do you write that? ...

RedirectToAction not refreshing the page.

I have a scenario where I am on a view page and calling a action method in controller A that calls another action in controller B via a RedirectToAction return, and this action returns the view that Im already on. I want the page to refresh to reflect the updates to the system state these two actions have made, but MVC seems to decide ...

MethodInfo.Invoke sometimes returns null and sometimes returns value

Hi all, I'm working on an asp.net MVC application. I have a class that wraps a repository that fetches data from a db using simple linq statement. I've written a decorator class to add caching logic (using caching application block). since I have several methods that I want to decorate, and the logic is all the same for each one (chec...

how can we mock static , read only members , and functions that reside within the same class?

I'm using MOQ with tdd, i'm comfortable with the simple mock objects. Now moving on to the complex objects(i.e., objects containing other objects as properties ). i have problem creating mocks for three scenarios. when the method being tested wraps a static method. when the method being tested wraps a read only property. when the metho...

Prefix and BindAttribute

Hello I have a problem with using the prefix, seems like whenever I use the Bind, the entire viewmodel's objects gets set to null on post. Atm I have: [Bind(Prefix = "User", Include = "Firstname,Username,Lastname,Email")]UserAdminEditViewModel userobj I've tried to use prefix "User." and "User_", only change is that only the "objuse...

Proper Exception Handling with ASP.NET MVC, ELMAH and custom Error Pages

Hi folks, consider the following situation: There is an ASP.NET MVC application which utilizes ELMAH for centralized ExceptionLogging. A Controller is marked with the HandlerError Attribute to catch a specific type of an exception and presents the user with a view. For example [HandleError(ExceptionType = typeof(ModelSpecificException...

How to access the elements of a list of array passed from the controller in javascript??

Hi, I am using Asp.net MVC and in the controller I have a function that generates a list of array i.e. List and after converting it to a view I am returning this to the view page.In the view page I am converting it to List by the following code: <% List<string[]> items = (List<string[]>)ViewData["Items"]; %> Now I want t...

Has anyone got any experience developing a site based on WebQuarters?

Hi, I'm in the process of planning out a site for a friend, they need to be able to modify site content, have a products section and shopping/ check-out area. All the products need to be able to be updatable too (descriptions, photos, cost - including delivery, etc). As I'm a bit of an ASP.NET MVC fanboy currently, I was going to build...

S#arp architecture vs straight IOC + NHibernate + MVC

Are the benefits enough to use another external assembly? How difficult is it to remove S#arp and keep NHibernate at a later point? ...

ASP.NET MVC Javascript ActionResult

Anyone have any examples of javascript actionresults? I am having a hard time getting the script to execute once it has been returned. Thanks ...

How to hide my menu for non authenticated users?

Hi. I have authenticated users to log on my system using this code: FormsAuthentication.SetAuthCookie(user, false); I want to hide my system menu for non authenticated users. Something like this: <% if(???) {%> <ul id="menu> ... </ul> <% } %> How can I do this? Thank you. ...

Why is my validation message generic? ASP.NET MVC

Hello SO: I wrote a custom validation handler for this ASP.NET MVC application. Here is a screenshot of the validation messages: As you can see, the title and director work fine but the date does not. The code I have for the Create view: <fieldset> <legend>Fields</legend> <p> <%= Html.Label("Title", "Title:") %> <%...

Html.LabelFor Specified Text [ASP.NET MVC 2]

Anyone got any idea on how to specify text when using Html.LabelFor(c=>c.MyField). It's just MyField might not be an appropriate name to display on screen, you may want "The Super Fantastic Field" instead, but there doesn't appear to be any overloads. Any ideas? ...

How to post data using jQuery and MVC

The data on my page is such: var userIdCol = '3,67,78,37,87'; This collection of used Id's is obtained from a Listbox via jQuery on my page. All I want to do is post this list of UserId's to my controller and display a success message somehere on my page. "Users have been updated." I am not sure what the signature of my controller s...

Questions about the Service Layer as Validation in asp.net mvc.

Hi I am a bit confused about the service layer and using it validation. So I am looking through this tutorial: http://www.asp.net/learn/mvc/tutorial-38-cs.aspx First if you look at List 3 using System.Collections.Generic; using System.Web.Mvc; namespace MvcApplication1.Models { public class ProductService : MvcApplication1.Model...

Login control in MVC not displaying username after account creation redirect.

I'm working with a custom asp.net membership provider in conjunction with the default Account controller that comes with the asp.net MVC example app. Everything is going smoothly except for one tiny thing: After a user creates an account and is automatically logged in and redirected, their username is not displayed with the usual welcome...

ASP.NET MVC OnException and Ajax Form onFailure

The situation I have is I am handling OnException in my controller. Depending on the type of exception I would like to return a javascript result. The action method that threw the exception was called by submitting an ajax form. The ajax form handles the success event. In my OnException method I am setting ExceptionHandled = true per...