Visual Studio Community Edition 2017 – Stop debugger when browser windows is closed, close browser when debugging stops

If you want to test threading that will still perform after closing down your browser, you need to still have the debugger running. In order to do that, you need to uncheck the box in the Tools/Options/Web Projects section that states:Stop debugger when browser windows is closed, close browser when debugging stops.

Please follow and like us:

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="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/
npm/daterangepicker/daterangepicker.min.js
"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.
net/npm/daterangepicker/daterangepicker.css
" /> 


 @if (ViewBag.Browser == "InternetExplorer")
    {
        <script type="text/javascript">
            var mFromDate = '@Model.Search.From_Date';
            if (mFromDate != "") {
                mFromDate = mFromDate.substring(0, mFromDate.search(/ /));
            }
                $('input[name="Search.From_Date"]').daterangepicker({
                    singleDatePicker: true,
                    showDropdowns: true,
                    dateFormat: "mm/dd/yyyy",
                    autoUpdateInput: true
                }, function (start, end, label) {
                    $('input[name="Search.From_
Date"]').val(start.format("MM/DD/YYYY"));
                }).val(mFromDate);
        </script>


        <script type="text/javascript">
            var mToDate = '@Model.Search.To_Date';
            if (mToDate != "") {
                mToDate = mToDate.substring(0, mToDate.search(/ /));
            }
                $('input[name="Search.To_Date"]').daterangepicker({
                    singleDatePicker: true,
                    showDropdowns: true,
                    dateFormat: "mm/dd/yyyy",
                    autoUpdateInput: true
                }, function (start, end, label) {
                    $('input[name="Search.To_Date"
]').val(start.format("MM/DD/YYYY"));
                }).val(mToDate);
        </script>
    }

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" })
                    }
                    else
                    {
                        <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)
                </div>

Please follow and like us:

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 () {
                RefreshParent();
            };
        </script>
    }

And in the Javascript section, add the function:

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

Please follow and like us:

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">
        window.close();
    </script>
    }

 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>

    <script>
        function CloseTab() {
            window.close();
        }
    </script>
Please follow and like us:

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>
            </div>
        </div>
    </div>
</div>
Please follow and like us:

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.

 $('#RefreshListButton').focus(); 

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

  <script type='text/javascript'>
$(document).ready(function () {           
$('#RefreshListButton').focus();       
});
</script>
Please follow and like us:

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.

Image

  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.
Please follow and like us:

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="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
    2. Remove only the Report Section header and footer tags (leave the child elements)
      <ReportSections>
      <ReportSection>
      
      ..................................
      
      </ReportSection>
      </ReportSections>
    3. Remove the entire ReportParametersLayout section
      <ReportParametersLayout>
      
      <GridLayoutDefinition>
      
      .....................................
      
      </GridLayoutDefinition>
      
      </ReportParametersLayout>
Please follow and like us:

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.

Please follow and like us: