h1

requiredfieldvalidator not working onclientclick

May 24, 2016

 

Requiredfieldvalidator not working onclientclick added in button.

Code  : This code will not execute required field validator

 <asp:Button ID="btnSubmit" runat="server" Text="Check" 
OnClick="btnSubmit_Click" 
OnClientClick="javascript:return confirm('Are you sure to Submit?')"
 ValidationGroup="Submit" />

use Page_ClientValidate() predefined function to avoid issue.

Solution :

 <asp:Button ID="btnSubmit" runat="server" Text="Check" 
OnClick="btnSubmit_Click" 
OnClientClick="return CheckToProceed();"
 ValidationGroup="Submit" />

Javascript ::

function CheckToProceed() {
 if (Page_ClientValidate()) {
return confirm('Are you sure to Submit?')
}
}

Reference : stackoverflow

Advertisements
h1

jQueryUI tooltip HTML support

April 15, 2016

The latest version of jQueryUI tooltip is not supporting HTML tags.

we can override the original functionality to start support HTML

Method 1 : overrides the default behavior

$(function () {
      $(document).tooltip({
          content: function () {
              return $(this).prop('title');
          }
      });
  });

Example : http://jsfiddle.net/Aa5nK/12/

Method 2 : override the tooltip widget

$.widget("ui.tooltip", $.ui.tooltip, {
    options: {
        content: function () {
            return $(this).prop('title');
        }
    }
});

Example : http://jsfiddle.net/Aa5nK/14/

Reference : stackoverflow

h1

Set Document mode standard/Edge in IE

September 2, 2015

set Document mode standard/Edge in IE
Code :

Add meta tag in web page
<meta http-equiv=”X-UA-Compatible” content=”IE=edge” />

If you are using .net you can add this to the web.config

<system.webServer>
    <httpProtocol>
     <customHeaders>
        <add name="X-UA-Compatible" value="IE=edge" />
      </customHeaders>
    </httpProtocol>
</system.webServer>
h1

Fetch stored procedure which contains “text”

June 4, 2015

Code :

SELECT ROUTINE_NAME, ROUTINE_DEFINITION
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE ‘%texttosearch%’
AND ROUTINE_TYPE = ‘PROCEDURE’
h1

JQuery focus() after last character in textbox not woking in IE – Solution

May 7, 2015

In other browsers $(‘#TextBox’).focus() this code will work. for IE we need to do something special!!! in code

Code :

Create a function:

(function($){
$.fn.setCursorToTextEnd = function() {
$initialVal = this.val();
this.val($initialVal + ‘ ‘);
this.val($initialVal);
};
})(jQuery);

also we need to use setTimeout.

setTimeout(function() {
$(‘#TextBox’).focus();$(‘#TextBox’).setCursorToTextEnd();
}, 100);

Source 1
Source 2

h1

jQgrid : Change search filter before submit

March 16, 2015

we can use beforeSearch event for toolbar searching
onSearch for advanced searching and single field search
Code :

$(“#list”).jqGrid(‘filterToolbar’, {
beforeSearch: function () { fnBeforeSearch(); }

});

///trim all data before submit to search
function fnBeforeSearch() {
var i, l, rules, rule, $grid = $(“#list”),
postData = $grid.jqGrid(‘getGridParam’, ‘postData’),
filters = $.parseJSON(postData.filters);

if (filters && typeof filters.rules !== ‘undefined’ && filters.rules.length > 0) {
rules = filters.rules;
for (i = 0; i < rules.length; i++) {
rule = rules[i];
rule.data = rule.data.trim();
}
postData.filters = JSON.stringify(filters);
}
}

h1

JqGrid sorting numeric value with blank and null

March 13, 2015

Code :

sorttype: function (cellValue) {
return isNaN(cellValue) ? -100000 : Number(cellValue);
}