Thursday, March 17, 2016

Asp.net MVC 4 bootstrap integration








When it comes to integration of the popular Bootstrap with Asp.Net MVC,. there are  plenty of tutorial that guide you on step-by-step instructions on installation. I found following article pretty easy to follow and install bootstrap without much hassle.

1. Using the NUGET Package manager
2. Without using the NUGET package manager

Cheers,
Samitha.



Tuesday, March 1, 2016

Disable all Element inside a div or table


If you ever wanted to disable all the elements inside a table or div. jQuery provides an easy way of doing it.


$("#tableName").find("input,button,textarea,select").attr("disabled", "disabled");

 You can also try the jQuery BlockUIplugin for Page or element level blocking.

Cheers,
Samitha

Thursday, January 21, 2016

asp.net textbox yellowing in Chrome

I came across this issue when working with textboxes (auto fill on)   and tested on chrome browser. The textboxes are rendered with a yellowish background color.

This can be resolved in two ways.

1. Using CSS
 input:-webkit-autofill
    {
    -webkit-box-shadow: 0 0 0px 1000px white inset;
    }

2.Using jQuery
if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) {
$(window).load(function(){
    $('input:-webkit-autofill').each(function(){
        var text = $(this).val();
        var name = $(this).attr('name');
        $(this).after(this.outerHTML).remove();
        $('input[name=' + name + ']').val(text);
    });
});}

Detailed discussion can be found here.

Cheers,
Samitha

Monday, December 28, 2015

Asp.net textbox allow < charactor to be saved

Normally, saving special characters such as < or > require special configuration settings to be enabled in web.config file and in the page itself.


1) Disable request validation in the page

<%@ Page title="test" .... ValidateRequest="false" %>

2) Set requestValidationMode in Web.config


      



This solution could expose unexpected security threads.  Jquery provides a nice workaround to overcome this issue by escaping < and > characters as shown below.

 function validateTxt() {
    $("textarea, input[type='text']").change(function () { //replaces in all text areas and textboxes
      html = $(this).val(); //get the value
      //.replace("a" , "b")  works only on first occurrence of "a"
      html = html.replace(/< /g, "<"); //before: if there's space after < remove
      html = html.replace(/
      $(this).val(html); //set new value
   });
}

$(function () {
      validateTxt();
});
More discussion regarding the topic can be found here.

Cheers,
Samitha

 

Friday, November 20, 2015

IE11 compatibility mode off doPostBack and PageRequestManager undefined

There seem to be a bug in the browser definition files that came with .NET 2.0 and .NET 4.

This issue can be fixed by installing following hot fix for .net framework 4.0.

If you are deploying the asp.net application this should be installed in the machine where the application is deployed.

Regards,
Samitha

Wednesday, November 18, 2015

SQL Search

Searching for a specific text used in SQL objects can be made easy with the use of Redgate's SQL Search.

Even though SQL server provides queries for finding texts or columns this tool provides you much more flexibility.

Read following link for more information and download.

Cheers,
Samitha

Friday, October 30, 2015

Detect IE compatibility mode and version using JavaScript

Even though it is not recommended, following Javascript can be used to detect the IE compatibility mode.


// Create new object

var ieUserAgent = {
init: function () {
 
var ua = navigator.userAgent;
this.compatibilityMode = false;

    if(ua.indexOf("MSIE") == -1){
        this.version = 0;
        return 0;
    }

    if(ua.indexOf("compatible") == -1){
        this.compatibilityMode = false;
        return 0;

    }else{
        this.compatibilityMode = true;
        return 0;
    }
}
};

// Initialize the ieUserAgent object
ieUserAgent.init();

Read this thread for more details of the script.

Cheers,
Samitha