Geeks With Blogs

News My Blog has been moved to
Michael Freidgeim's Blog My Blog has been moved to April 2012 Entries
Log JavaScript errors to the server.
Some time ago I found debugging - Automatic feedback on JavaScript error - Stack Overflow. and the discussion has links to Logging JavaScript Errors To ASP.NET(Unfortunately the link to download in the post is broken).and custom control to help log JavaScript errors by sending error information to the server downloaded solution from When I wanted to include dll into my solution dependencies, I decided to rename WebControls.DLL ......

Posted On Wednesday, April 25, 2012 11:55 AM

Case-insensitive Contains extension for list of strings
I wanted to have case-insensitive Contains method for list of strings.Overload Enumerable.Contains<TSou... Method (IEnumerable<TSource>, TSource, IEqualityComparer<TSourc... expects custom IEqualityComparer class.I was about to create my own class IgnoreCaseEqualityComparer : IEqualityComparer<string... then found StringComparer.Create Method, that allow to use standard class.public static bool ContainsString(this IEnumerable<string> collection, string toFind, bool ......

Posted On Wednesday, April 18, 2012 10:29 PM

Select tool to minimize JavaScript and CSS size
There are multiple ways and techniques how to combine and minify JS and CSS files.The good number of links can be found in and in There are 2 major approaches- do it during build or at run-time.In our application there are multiple user-controls, each of them required different JS or CSS files, and ......

Posted On Sunday, April 15, 2012 8:08 PM

ReplaceBetweenTags function with delegate to describe transformation
I've created a function that allow to replace content between XML tags with data, that depend on original content within tag, in particular to MAsk credit card number.The function uses MidBetween extension from My StringHelper class /// <summary> /// /// </summary> /// <param name="thisString"></p... /// <param name="openTag"></para... /// <param name="closeTag"></par... /// <param name="transform"></pa... /// <returns></returns... ......

Posted On Sunday, April 15, 2012 1:01 PM

Code style Tip: Case insensitive string comparison
Goodif (String.Compare(myString, ALL_TEXT, StringComparison.OrdinalIgn... == 0) { return true; }OK(not obvious what true means) if (String.Compare(myString, ALL_TEXT, true) == 0) { return true; }BAD: (non null safe) if (myString.ToLower()==ALL_TE... { return true; } ......

Posted On Sunday, April 15, 2012 12:34 PM

Dump an arbitrary object To Html String
For debugging purposes me and my collegue wanted to dump details of the arbitrary object, and created function that uses LINQPad Dump functionality (thanks to and original discussion) public static string DumpToHtmlString<T>(this T objectToSerialize) { string strHTML = ""; try { var writer = LINQPad.Util.CreateXhtmlWri... ......

Posted On Saturday, April 14, 2012 2:50 PM

Disable messages from SQL Server “Login failed for user” in Event log
I’ve noticed multiple messages from SQL Server in EventLog on my machineLogin failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. Reason: Token-based server access validation failed with an infrastructure error. Check for previous errors. [CLIENT:]I’ve found that there are machines of my co-workers, but they were not sure, which processes tried to access my SQL server.I’ve tried a few things and finally in SQL Server Configuration Manager disabled tcp, as it was suggested in ......

Posted On Saturday, April 14, 2012 2:14 PM

Specify Linq To SQL ConnectionString explicitly
When modifying Linq to Sql data model in Visual Studio 2010, it re-assigns ConnectionString that is available on developer’s machine. Because the name can be different on different machines, Designer often replace it with something like ConnectionString1, which causes errors during deployment.It requires developers to ensure that ConnectionString stays unchanged. More reliable way is to use context constructor with explicit ConnectionString name instead of parameterless default constructor GOOD: ......

Posted On Saturday, April 14, 2012 1:44 PM

Do not expose enum in WCF response
We had a backward compatibility problem in WCF client, when in Service application a new value was added to one of enums. We discussed different ways to avoid this backward compatibility issues, and I found recommendation do not expose enum in wcf response in is still required to create new versions of our service interfaces to replace each enum fields with string field, that expects only documented values, and describe, what should be default behavior, ......

Posted On Saturday, April 14, 2012 12:18 PM

Visual Studio 10 crashed when tried to open one of solutions
Visual Studio 10 crashed when I tried to open one of my solutions. Closing Visual Studio and rebooting the machine didn’t help.The error message that was logged(see below), didn’t give any useful ideas.Finally It was fixed after I’ve deleted MySolution.suo file, which was quite big, and also Resharper folders.Log Name: ApplicationSource: Application ErrorEvent ID: 1000Task Category: (100)Level: ErrorKeywords: ClassicUser: N/ADescription:Faulting application name: devenv.exe, version: 10.0.40219.1, ......

Posted On Saturday, April 14, 2012 10:49 AM

Translate jQuery UI Datepicker format to .Net Date format
I needed to use the same date format in client jQuery UI Datepicker and server ASP.NET code. The actual format can be different for different localization cultures.I decided to translate Datepicker format to .Net Date format similar as it was asked to do opposite operation in Note that replace command need to replace whole words and order of calls is importantFunction that does ......

Posted On Saturday, April 14, 2012 10:40 AM

Copyright © Michael Freidgeim | Powered by: | Join free