Friday, October 18, 2019

Including js file

We can uses jQuery to import, include or require a js file within another js as shown below.


$.getScript("filename.js", function(){

   alert("filename.js loaded.");

});

Cheers,
Samitha

Tuesday, September 17, 2019

Chrome missing layout options in print preview

When trying to print a website in Chrome, you might see that print preview does not display the layout options to select.

This can be cause by two things.

1.Setting a custom @page size declaration in the Print  CSS
2. Integration of bootstrap


In both the above cases a custom @page size is given in the Print CSS and make sure you have set size: auto;  as shown below to resolve the issue.

@media print {
    @page {
        size: auto;
    }
}

Cheers,
Samitha

Tuesday, August 27, 2019

asp.net override style of an iframe

We can use jQuery to style the body or an element in an IFRAM E as shown below.


<script type="text/javascript">

$('#iframeID').load( function() {
    $(#'iframeID').contents().find("head")
       .append($("<style type='text/css'>  .className{display:none;}  </style>"));
});

</script>

Cheers,
Samitha

Friday, August 16, 2019

Remove resize grip on multiline textboxes

We can use css to easily remove the resize grip shown on multi line text boxes as shown below.

<style type="text/css">

textarea {
   resize: none;
}

</style>

Cheers,
Samitha

Wednesday, July 31, 2019

Restrict special characters

You can use JavaScript key press event to restrict special characters as shown below.

<script type="text/javascript">

 //this event can be attached in pageLoad or DOM Ready
function pageLoad() {

 var specialCharsArray = [61, 62, 33, 36, 64, 35, 37, 94, 38, 42, 40, 96, 126, 40, 41, 43];
//this array can be used to specify all the special characters

//the element can be an id of a textbox or in general input type=text
                element.bind("keypress", function (event) {
                     //check array
                    if ($.inArray(event.which, specialCharsArray ) != -1) {
                        event.preventDefault(); //prevent default event handle
                    }
                });

}
</script>



Use this link to test key code values.

Cheers,
Samitha

Wednesday, June 26, 2019

Visual Studio 2017 and SQL Server 2017 Installation issues

If you have decided to migrate to Visual Studio 2017 or later editions, there are few thing that will ensure a smooth installation and a working environment without much hassle.

Installing  SQL Server 2017 before installation of Visual Studio 2017 will ensure that SQL Server 2017 is install without an error..

If you have installed Visual Studio 2017 first  then the SQL Server 2017 setup will be failed with exit code 1638.

To resolve this uninstall the Microsoft Visual C++ 2017 redistributable as shown here.

In addition you will receive following error when trying to open SSMS.

Cannot find one or more components. Please re install the application

This can be resolved by

1. Reinstall the VS 2015 Shell (using Visual Studio 2017 setup)
2. Try to reopen SSMS. It if still fails try reinstalling SSMS.

Cheers,
Samitha

Monday, June 10, 2019

Resolving Maximum request length exceeded error

You might encounter Maximum request length exceeded error when you try to upload large files or perform web requests that fetch large chunks of data.


This error commonly raised by IIS as the default upload file size or request size is only 4MB.
There are two settings in the web.config that determined the request length. The following settings will increase the request  up to 100 MB.
 
<configuration>
    <system.web>
        <httpRuntime maxRequestLength="102400" />
   </system.web>
</configuration>
 
&lt;system.webServer>
   &lt;security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="104857600" />
      </requestFiltering>
   </security>
</system.webServer> 
 
Please note that maxRequestLength is measured in Kilobytes 
and maxAllowedContentLength is measured in bytes.
 
 
Also note that this can be configured for the URL 
that performs the file upload/ request.
 
e.g.
 
<location path="Documents/Uploads">
<system.web>
    
   <httpRuntime maxRequestLength="102400" />
  </system.web>
  <system.webServer>
   <security>
     <requestFiltering>
       
        <requestLimits maxAllowedContentLength="104857600" /> 
      </requestFiltering>
    </security>
  </system.webServer>
</location> 

Cheers,
Samitha