Categories
Programming Tips

Simple Code in C# to Convert DateTime object to the “datetime-local” type used in input controls with MongoDB Driver

As the title suggests, the following code converts a DateTime object to the “datetime-local” type used in HTML5 input controls (i.e. format 2016-10-30T00:00:00.00).  I developed this while working on a personal application using C# and MongoDB.  It uses the ToJson() function/method of the MongoDB Driver.

using MongoDB.Driver;
using System;

Datetime dt = new DateTime();
var dtLocal = dt.ToJson().ToString().Replace("ISODate(\"", "").Replace("Z\")", "");

Hopefully by posting this, it will help others save time.

Categories
Errors

Another Cause for the Resource interpreted as but transferred with Error

In a previous article, I described what could cause this error.  While helping a customer the other day, we discovered another culprit, password protecting a directory.  The solution is to put the resources (i.e. .css, .js, image files, etc.) in a location which is publicly accessible (i.e. not under directory tree which has been password protected).  I also think this error may be particular to Chrome’s Developer  Tools.  The customer was using Internet Explorer, and this was the error that was thrown instead:

SEC7113: CSS was ignored due to mime type mismatch.

Categories
Programming Tips

Tip for Ajax Control Toolkit MultiHandleSlider

I wrote this tip down for myself when I had problems getting the Ajax Control Toolkit MultiHandleSlider to work correctly in my application years ago. If you’re having difficulties as well, try setting the ID and BehaviorID properties to the same value.