Search Results

Search found 6 results on 1 pages for 'jeriley'.

Page 1/1 | 1 

  • Validation in asp.net MVC - validation only to happen when "asked"

    - by jeriley
    I've got a slightly different validation requirement than the usual "when save, validate!". The system can allow someone to update a bunch of times without being "bothered" with a validation listing UNTIL they say it's complete. I thought I might be able to pull a fast one and put the [HandleError] on the method of which this would fire, but that validates every save. Is there an attribte I can put into my custom validator that can handle this or am I going to have to write up my own HandleError attribute?

    Read the article

  • Conditional OrderBy

    - by jeriley
    So, right now I've got a number of columns the user can sort by (Name, County, Active) and that's easy but messy. Looks something like this... Select Case e.SortExpression Case "Name" If (isDescending) Then resultsList.OrderByDescending(Function(a) a.Name).ToList() Else resultsList.OrderBy(Function(a) a.Name).ToList() End If Case "County" ... and so on what I would LIKE to do, is something more ... graceful, like this Private Function SortThatList(ByVal listOfStuff As List(Of Stuff), ByVal isDescending As Boolean, ByVal expression As Func(Of Stuff)) As List(Of Stuff) If (isDescending) Then Return listOfStuff.OrderByDescending(expression) Else : Return listOfStuff.OrderBy(expression) End If End Function but it doesn't like the datatype (Of TKey) ... I've tired Func(Of stuff, boolean) (got something in c# that works nicely like that) but can't seem to get this one to do what I want. Ideas? What's the magic syntax?

    Read the article

  • Asp.net MVC 2, MvcContrib, and a base controller with redirect actions

    - by jeriley
    I've got a base controller that takes a couple generics, nothing overly fancy. public class SystemBaseController<TForm, TFormViewModel> : Controller where TForm : class, IForm where TFormViewModel : class, IViewModel ok, no big deal. I have a method "CompleteForm" that takes in the viewModel, looks kinda like this ... public ActionResult CompleteForm(TFormViewModel viewModel) { //does some stuff return this.RedirectToAction(c => c.FormInfo(viewModel)); } Problem is, the controller that inherits this, like so public class SalesFormController : SystemBaseController<SalesForm, SalesViewModel> { } I end up getting a error from MvcContrib - Controller name must end in 'Controller' at this point ... public RedirectToRouteResult(Expression<Action<T>> expression) : this(expression, expr => Microsoft.Web.Mvc.Internal.ExpressionHelper.GetRouteValuesFromExpression(expr)) {} The expression that's passed in is correct (SystemBaseController blahblah) but I'm not sure why its 1.) saying there's no controller at the end, and 2.) if I pull out everything into the controller (out of the base), works just fine. Do I need to write or setup some kind of action filter of my own or what am I missing?

    Read the article

  • Moq, a translator and an expression

    - by jeriley
    I'm working with an expression within a moq-ed "Get Service" and ran into a rather annoying issue. In order to get this test to run correctly and the get service to return what it should, there's a translator in between that takes what you've asked for, sends it off and gets what you -really- want. So, thinking this was easy I attempt this ... the fakelist is the TEntity objects (translated, used by the UI) and TEnterpriseObject is the actual persistance. mockGet.Setup(mock => mock.Get(It.IsAny<Expression<Func<TEnterpriseObject, bool>>>())).Returns( (Expression<Func<TEnterpriseObject, bool>> expression) => { var items = new List<TEnterpriseObject>(); var translator = (IEntityTranslator<TEntity, TEnterpriseObject>) ObjectFactory.GetInstance(typeof (IEntityTranslator<TEntity, TEnterpriseObject>)); fakeList.ForEach(fake => items.Add(translator.ToEnterpriseObject(fake))); items = items.Where(expression); var result = new List<TEnterpriseObject>(items); fakeList.Clear(); result.ForEach(item => translator.ToEntity(item)); return items; }); I'm getting the red squigglie under there items.where(expression) -- says it can't be infered from usage (confused between <Func<TEnterpriseObject,bool>> and <Func<TEnterpriseObject,int,bool>>) A far simpler version works great ... mockGet.Setup(mock => mock.Get(It.IsAny<Expression<Func<TEntity, bool>>>())).Returns( (Expression<Func<TEntity, bool>> expression) => fakeList.AsQueryable().Where(expression)); so I'm not sure what I'm missing... ideas?

    Read the article

  • two UserControls, one page, need to notify each other of updates

    - by jeriley
    I've got a user control thats used twice on the same page, each have the ability to be updated (a dropdown list gets a new item) and I'm not sure what might be the best way to handle this. One concern - this is an older system (~4+ years, datasets, .net2) and it is amazingly brittle. I did manage to have it run on 3.5 with no problems, but I've had a few run-ins with the javascript validation (~300 lines per page) throwing up all over the place when I change/add/modify controls in the parent.

    Read the article

  • Conditional Required Attribute for validation

    - by jeriley
    We're trying to get a conditional attribute to work, case in point, there's a boolean (checkbox) that if checked, its related text is required. So, ideally we'd have something like ... public bool Provision { get; set; } [ConditionalRequirement(IsNeededWhenTrue = Provision)] public string ProvisionText { get; set; } Is this even possible? Alternate idea (not as elegant?) public bool Provision2 { get; set; } [PropertyRequired(RequiredBooleanPropertyName = "Provision2")] public string Provision2Text { get; set; } I'd hate to use the magic string method ... but any other ideas?

    Read the article

1