Support for debugging lambda expressions with Visual Studio 2015 – Microsoft Application Lifecycle Management – Site Home – MSDN Blogs

Support for debugging lambda expressions with Visual Studio 2015 – Microsoft Application Lifecycle Management – Site Home – MSDN Blogs.

String.format for javascript (C# .NET like syntax for concatenating strings)

Here is a little hack to make javascript behave more like .NET with string.format…

usage:

var selector = String.format("#container{0} div.lineItem{1}[data-entryid='{2}']", containerId, itemId, entryId);

js code:

//String.format for js.
if (!String.format) {
String.format = function (format) {
var args = Array.prototype.slice.call(arguments, 1);
return format.replace(/{(\d+)}/g, function (match, number) {
return typeof args[number] != 'undefined'
? args[number]
: match
;
});
};
}

From: http://stackoverflow.com/questions/610406/javascript-equivalent-to-printf-string-format/4673436#4673436

Setting EPiServer 6r2 PageTypeBuilder Default Property Values

This is how you set default values for PTB 2.0 poperties in Episerver 6r2:
In the [PageTypeProperty] method attribute, add:

DefaultValue = 0, 
DefaultValueType=EPiServer.DataAbstraction.DefaultValueType.Value,

E.g.:

[PageTypeProperty(SortOrder = 100,
Tab = typeof(RelatedContentTab),
EditCaption = "Related content sort index",
Type = typeof(PropertyNumber),
DefaultValue = 20,
DefaultValueType = DefaultValueType.Value)]
int RelatedContentSortIndex { get; set; }

The DefaultValue could be any type of object. The EPiServer.DataAbstraction.DefaultValueType.Value is just an enum that indicates that a default value should be used.

However this has to be done before the page is created for the first time, else it wont have any effect until next time a page is created.

See: http://pagetypebuilder.codeplex.com/workitem/7831
Another approach, if suitable, could be to just add the “Required” in the first place to avoid missing values from the editors.

E.g.:

[PageTypeProperty(SortOrder = 100,
Tab = typeof(RelatedContentTab),
EditCaption = "Related content sort index",
Type = typeof(PropertyNumber),
Required = true)]
int RelatedContentSortIndex { get; set; }

 In EPiServer 7 this approach can be used:
See below heading “Default property values” here:
http://www.david-tec.com/2012/06/Comparing-PageTypeBuilder-and-EPiServer-7-Preview-typed-pages-part-3-of-3/