Sunday, August 18, 2013

Declare a Predicate Delegate inline (options)

  • explicit delegate:
myObjects.RemoveAll(delegate (MyObject m) { return m.X >= 10; });

  • lambda
myObjects.RemoveAll(m => m.X >= 10);

Wednesday, May 29, 2013

List all Model ModelState Errors MVC


List<string> errorsList = new List<string>();
foreach (ModelState modelState in ViewData.ModelState.Values)
{
          foreach (ModelError error in modelState.Errors)
         {
            errorsList.Add(error.ErrorMessage);
         }
}
foreach (var item in errorsList)
{
       ModelState.AddModelError("", item);
}
     

Monday, April 1, 2013

AddThis reload on ajax load

run the code on ajax load, or put it on the end of file that is loaded


var addthis_url = "http://s7.addthis.com/js/250/addthis_widget.js#pubid=your_id";
if (window.addthis) {
    window.addthis = null;
    window._adr = null;
    window._atc = null;
    window._atd = null;
    window._ate = null;
    window._atr = null;
    window._atw = null
}
$.getScript(adthis_url)



From:
http://railsforum.com/viewtopic.php?id=50604

Wednesday, January 30, 2013

Change app behaviour when debug="true" on web.config


To check if debug="true" on web.config, check the following:

HttpContext.Current.IsDebuggingEnabled

Why should I care?

Take the example
try{
//a lot of code that makes something
}catch (Exception ex){
//Make the error handling of some sort, like log the error...
if(HttpContext.Current.IsDebuggingEnabled){
return ex.Message;
}else{
return "A error ocurred with the app, please retry again later or contact our it department";
}
}


Wednesday, January 23, 2013

Full intelisense mvc umbraco 6

From  @ twitter
Tip for   developers, when editing MVC Views in add " Umbraco.Web;" to top of cshtml for full Intellisense

Tuesday, January 8, 2013

Thursday, January 3, 2013

Url Picker uComponents

uComponents.DataTypes.UrlPicker.Dto.UrlPickerState picker = uComponents.DataTypes.UrlPicker.Dto.UrlPickerState.Deserialize(curr.GetProperty<string>("propAlias"));


string target = picker.NewWindow ? "_blank" : "_self";
string text = picker.Title;
string url = picker.Url;