MVC 5 – Third Party Date Picker that works in IE

First, send back the browser type from the controller to the browser.

ViewBag.Browser = Request.Browser.Browser; 

Add the following javascript:

<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src="
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.
" /> 

 @if (ViewBag.Browser == "InternetExplorer")
        <script type="text/javascript">
            var mFromDate = '@Model.Search.From_Date';
            if (mFromDate != "") {
                mFromDate = mFromDate.substring(0, /));
                    singleDatePicker: true,
                    showDropdowns: true,
                    dateFormat: "mm/dd/yyyy",
                    autoUpdateInput: true
                }, function (start, end, label) {

        <script type="text/javascript">
            var mToDate = '@Model.Search.To_Date';
            if (mToDate != "") {
                mToDate = mToDate.substring(0, /));
                    singleDatePicker: true,
                    showDropdowns: true,
                    dateFormat: "mm/dd/yyyy",
                    autoUpdateInput: true
                }, function (start, end, label) {

And check the browser type in order to use the default HMTL date picker when not Internet Explorer.

<div class="col-md-2" style="padding-left: 0px;">
                    @Html.LabelFor(m => m.Search.From_Date, new { style = "font-weight:bold; margin-bottom: 0px;" })
                    <br />
                    @if (ViewBag.Browser != "InternetExplorer")
                        @Html.EditorFor(m => m.Search.From_Date, new { @class = "form-control", name = "FromDate" })
                        <input type="text" name="Search.From_Date" id="Search.From_Date" autocomplete="off"  style="height: 35px;" placeholder="mm/dd/yyyy" />
                    @Html.ValidationMessageFor(m => m.Search.From_Date)

MVC 5 – Refresh Parent Window After Executing Child Window

Close a windows tab upon returning a view:

Do this when a parent window opens a child window.

The child window does the processing, but after the processing, you want the parent window to refresh.

In the SAVE action of the controller of the view of child window put:

ViewBag.RefreshGrid = false; 

at the top of the action, and

ViewBag.RefreshGrid = true; 

Right before the return of the view.

Now, in the save view mentioned above, put this javascript logic below the Html.BeginForm:

if (ViewBag.RefreshGrid == true)
        <script type="text/javascript">
            window.onload = function () {

And in the Javascript section, add the function:

<script type="text/javascript">
        function RefreshParent() {
            if (window.opener != null && !window.opener.closed) {

MVC 5 – How to Close a Browser Tab Using Javascript

Close a windows tab upon returning a view:

    @if (ViewBag.CloseWindow == true)
    <script type="text/javascript">

 Closing a Windows tab via a button click while on view:

<button style="font-weight:bold; margin-top: 5px;" type="button" onclick="CloseTab();" class="btn btn-primary">Close Tab</button>

        function CloseTab() {

MVC 5 – How to Display a PDF in a View

Assuming that you have a PDF in your controller as a byte array, add the following code to convert the data to a base64 string and send to your view.

string imageBase64Data = Convert.ToBase64String(results);
string imageDataURL = string.Format("data:application/pdf;base64,{0}", imageBase64Data);
ViewBag.ImageData = imageDataURL;

 In your view, display the PDF in an iframe.

 <div class="container">
    <div class="row">
        <div class="form-group-sm">
            <div class="col-md-12" style="padding-left: 0px;">
                <iframe style="width: 75%; height: 500px;" src="@ViewBag.ImageData"></iframe>

MVC 5 – Using Javascript to set focus to control, textbox, button, dropdown list upon loading of a Razor View

Let’s say you want to add focus to a button in your view. The first thing you need to do is add the id attribute to your control and give it a name such as id=”RefreshListButton”.

Next, in the jquery document ready section, add a jquery function that will set the focus.


 $(document).ready(function () Here is the complete function:

  <script type='text/javascript'>
$(document).ready(function () {           

Windows 10 – Window System Image Backup fails error code (0x807800C5) (0x80070020)

There was a failure in preparing the backup image of one of the volumes in the backup set.
The process cannot access the file because it is being used by another process.

All I can tell you folks is what worked for me.


  1. Try and shutdown the computer (not a restart).
  2. Turn on your computer and try again.
  3. If that don’t work, run these command in an elevated (administrator) command prompt.
    1. DISM.exe /Online /Cleanup-image /Scanhealth
    2. DISM.exe /Online /Cleanup-image /Restorehealth
    3. Shutdown the computer (not a restart).
    4. Turn on your computer and try again.
  4. If that doesn’t work, in an elevated (administrator) command prompt, run:
    1. sfc /scannow
    2. If that checks out okay, in the same windows, run a chkdsk:
      1. chkdsk [Drive:] [parameters]  “Example:” chkdsk c: /f /r /x
      2. Enter Y in order to have this process run the next time the system restarts.
      3. Restart your system.
  5. If this doesn’t work, browse the web and find another solution.

SQL Server Reporting Services – Opening an RDL in Older Version of Visual Studio Opens as XML

In order to fix this issue, you need to remove a few lines of code from the XML.

    1. Replace xmlns with:
      <Report xmlns="" xmlns:rd="">
    2. Remove only the Report Section header and footer tags (leave the child elements)
    3. Remove the entire ReportParametersLayout section

Visual Studio Community Edition 2017 – VS Freezes when Accessing Context-Menu on SSRS .rdl Reports

Sometimes when I attempt to deploy a report to my Reporting Services Server, Visual Studio freezes for a minute or more before bringing up the context menu. After some research, my problem was resolved by disabling the Image Optimizer extension. To disable:

  1. Click the Tools Menu.
  2. Click Extensions and Updates.
  3. Look or Search for Image Optimizer.
  4. Click the extension.
  5. Click the disable button.

Hopefully, Microsoft will fix this issue soon.

Visual Studio Community Edition 2017 – Locked File or Folder with Visual Studio Installer

Quote: “The solution I found was to close down visual studio, go to “c:\Program Files (x86)\Microsoft Visual Studio\Installer”, rename the folder “Installer” to something else then run vs_installer.exe from the renamed folder.

Windows 10 – Use CHKDSK to fix problems with your hard drive

  1. Raise an elevated command prompt.
  2. Type in CHKDSK   /f   /r   /x
    1. /f  parameter tells CHKDSK to fix errors that it finds.
    2. /r parameter tells CHKDSK to repair to find the bad sectors and try and recover the readable information.
    3. /x parameter tells CHKDSK to dismount the drive before beginning the process.
  3. If your drive is a boot disk (As in your main hard drive that contains your OS, after entered, a message will popup stating the CHKDSK can’t be done while the computer is using the drive. Select Yes to schedule the CHKDSK when a Restart of the computer is executed.
  4. Restart your computer. The Scan and Repair will happen.
  5. When complete, you can look at the log of your CHKDSK by bringing up the Event Viewer.
    1. Click Windows Logs
    2. Right Click Application and click Find…
    3. Enter Chkdsk (Find looks at the Source column)  and click the Find Next button.
    4. If found, cancel out of the Find dialog box, and then read the log in the General Tab of the middle windows of the event viewer.
  6. To create a text file of the actual log, do the following:
    1.  Click Start, and in the search box, type and then click Windows Powershell. Powershell will bring up a dialog box.
    2. Enter the following at the command prompt:
      1. get-winevent -FilterHashTable @{logname=”Application”;}| ?{$_.providername –match “Chkdsk”} | fl timecreated, message | out-file Desktop\CHKDSKResults.txt
  7. Go to your Desktop and read the log file.