Monday, April 25, 2016

Bootstrap layout generator

Since twitter introduced BootStrap, there has been plenty of resources that aid in building bootstrap layouts. Now the developers simply can try one of free online layout builders and generate the layout online.
This article discusses some of the available online bootstrap layout generators and I found layoutit to be very use full.


Tuesday, April 12, 2016

ASP.Net keep textbox passoword on postbacks

As a security measure , text inputted to a password textbox is cleared on post backs. If any of you come across a situation where it needs to be keep password visible on post backs, it would be not as straightforward as you might have think.

Achieving this objective involves following steps.

1. Textbox definition (in the .aspx page)

2. PageLoad code behind
 txtAdminPWD.Attributes("type") = "password"

 If ViewState("Password") IsNot Nothing Then
            txtAdminPWD.Attributes.Add("value", ViewState("Password").ToString())
 End If

3.  Password stored to the textbox in the value and in view state (can be inside a method to populate the password )
ViewState("Password") = Decrypt(cUser.AdminPWD).ToString()
                txtAdminPWD.Attributes.Add("value", Decrypt(cUser.AdminPWD).ToString())

4.Use the javascript PageLoad to restore password textbox value
function pageLoad() {
                setTimeout(function () {
                }, 10);

5. Clearing the password
txtAdminPWD.Text = ""
txtAdminPWD.Attributes.Add("value", txtAdminPWD.Text)


Thursday, March 17, 2016 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


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.


Thursday, January 21, 2016 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
    -webkit-box-shadow: 0 0 0px 1000px white inset;

2.Using jQuery
if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) {
        var text = $(this).val();
        var name = $(this).attr('name');
        $('input[name=' + name + ']').val(text);

Detailed discussion can be found here.


Monday, December 28, 2015 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 () {
More discussion regarding the topic can be found here.



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 application this should be installed in the machine where the application is deployed.