Skip to main content

Posts

Showing posts from August, 2013

sorting array in JavaScript

Hi All, I'm going to explain to  sorting array in JavaScript . Today's, I have a requirement to sorting array using JavaScript. JavaScript have to Array.sort() method is default ascending order. var empArray = ['x', 'a', 'z', ‘b’]; empArray.sort(); //Output: a, b, x and z. These Code samples are working on mostly all browsers (IE, Mozilla, and Firefox etc.) In the 1st step , Code Sample for JavaScript sorting Array objects < script type ="text/javascript" lang ="ja">        //Employee array collections.     var employeeArray = [         { empName: "Anil" , empEmail: "anil.s@dotnetsql.in" , empAge: 29 },         { empName: "Sunil" , empEmail: "sunil.s@dotnetsql.in" , empAge: 22 },         { empName: "Sushil" , empEmail: "sushil.s@dotnetsql.in" , empAge: 19 },         { empName: "Reena" , empEmail: "reena.s@dotn

Sorting an Observable Array in Knockout JS

Hi All, I'm going to explain to  sorting an observable array in knockout JS Today's, I have a requirement for sorting an observable array with respect to the date as give below example. The below code sample are working most of the browsers (IE, Mozilla, and Firefox etc.) In the 1st step , code-sample for knockout Js Example : < script type ="text/javascript" lang ="ja">     // This observable-array contains to 3 user objects.     var userDetails = ko. observableArray ([         { name: "Anil Singh" , date: "10/03/1984" },         { name: "Sunil Singh" , date: "05/04/1990" },         { name: "Sushil Singh" , date: "13/06/1999" }     ]);     //sort observable array to date wise entries.      userDetails  .sort( function (l, r) {         return (Date.parse(l.date) == Date.parse(r.date) ? 0 :                                                 (Date.pars

allow only numbers in textbox javascript

Hi All, I'm going to explain to  allow only numbers in  text-box  using JavaScript Today's, I have a requirement to allow only numbers in the contact no., hours, Id etc. textbox using JavaScript, want to allow only numbers or digits and the  alphabetic  and special  characters (A to Z a to z.,@#!$%^&*()_+=|\ etc.) are not allowed in the  text-box . These Code samples are working on mostly browsers (IE, Mozilla, Firefox etc.) In the 1st step , Code Sample for HTML/ASP.Net HTML : <iput id= "txt_PhoneNo" type= "text" name= "txt_PhoneNo"   onkeypress= "return allowNumbersOnly(keyEvent);" > ASP.Net : < asp : TextBox id ="txt_PhoneNo" onkeypress ="return allowNumbersOnly (keyEvent);" runat ="server" /> In the 2st step , Code Sample for JavaScript < script type ="text/javascript" lang ="ja">     //Is used to check the only

exception handling in javascript

Hi All, I'm going to explain exception handling in JavaScript Today's, I have a requirement to exception handling in JavaScript and want to send the error messages and stack to support team for solving to the problem. That time, we can use to try/catch/finally and get the exact error and send to the support team. In the 1st step , Code Sample for Exception Handling in JavaScript Application try {     $( '#progressBar' ).block();     //Todo: Application logic here. } catch (ex)  {      console.log(ex.message);     console.log(ex.stack);     //Call to track exception method to stor the exception and print.     getEceptions(ex); } finally   {        $( '#progressBar' ).unblock(); } //Get exceptions method. function  getEceptions(ex) {     var self = this ;     self.message = ex.message;     self.stack = ex.stack; };

send email using JavaScript

I am going to share the code sample for  send email using JavaScript in MVC 5 Today's, I have a requirement to send the error report by default email in all browsers using JavaScript. In the 1st step , Write the JavaScript code sample.  $( '.div_confimpopup' ).find( '.btn_SendReport' ).click( function () { //Need to send the error detail to dotnetsql.in support team with error details.    var mesgDetails = 'mailto:support@dotnetsql.in?subject='  + 'UserName : ' + username             + '  ||  SubscriptionId : ' +subscriptionId     + '&body='  + 'UserName : ' + username                    + ',  SubscriptionId : ' + subscriptionId                    + ',  RequestURL : ' + requestURL                    + ',  Error Message : ' + internalErrorMsg;    window.location. href = mesgDetails;    return ; });   Notes: After click on Send Report open to defa

How to disable browser back button using JavaScript & MVC 5?

How to disable browser back button using JavaScript & MVC 5? How do I get a browser back button event using JavaScript? Hello everyone, Today's I have a requirement to disable browsers back button in MVC 5 projects , I have fixed the the above problem using the below  example code. Table of Contents : JavaScript code C# code for MVC ActionResult Step 1. The JavaScript Code sample The  javascript code put master page of the application for disable the browser back button.   ? 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 //This is JavaScript code for "disable browsers back button.   <script type="text/javascript">            function disableBackButtonAllBrowsers() {              window.history.forward()          };          window.onload = disableBackButtonAllBrowsers();          window.onpageshow = function (evts) {                          if (evts.persis

Enter key press event in jquery

I am going to share the code sample for  Enter key press event in jquery Table of Content  1. Code sample for HTML 2. Code sample for jQuery In the 1st step , we write HTML code for text-box where i can type text to search and apply to key-press event on search image button in jquery. HTML  < input type ="text" id ="txtSearchIcon" / >  < img src ="~/Images/icon_search.png" id ="imgSearchIcon" /> In the 2nd , write to jquery code jQuery // Enter key press to search by search icon. < script type ="text/javascript">     $( function () {         $( '#txtSearchIcon' ).on( ' keypress ' , function (event) {             if (event.keyCode == 13) {                                                  $( "#imgSearchIcon" ).click();             }         });     }); </ script >

allow only numbers in textbox jquery

I am going to share the code sample for how to  allow only numbers in the textbox field using jQuery. Table of Content 1. HTML code sample 2. jQuery code sample In the 1st step , we write HTML code for text-box where i can apply to onkeypress event and call to JavaScript method. HTML : < input type ="text" id ="txtFilter" onkeypress ="return isNumberFilter(keyEvent)"/> jQuery : In the 2nd,  code sample for jQuery as given below. < script type ="text/javascript">      function isNumberFilter(keyEvent) {          var keyResult = (keyEvent.which) ? keyEvent.which : event.keyCode          if (keyResult > 31 && (keyResult < 48 || keyResult > 57))              return false ;          return true ;      } </ script >

What's New in ASP.NET MVC 5?

The MVC is a framework, standard pattern for developing Web applications and MVC framework handled by three objects Model, View and Controller. What's New in ASP.NET MVC 6? MVC 5 Key Features - 1.       One ASP.NET 2.       ASP.NET Identity 3.       Bootstrap 4.       Authentication filters 5.       Filter overrides 6.       Attribute routing In detail - 1.       MVC 5 introduced to ASP.NET Identity for authentication and identity management. 2.       ASP.NET Identity is a new Membership provider to handle the authentication and authorization for social networking site just like Google , twitter, face-book etc. 3.       MVC 5 added  to authentication filters for authenticate to users using  third party authentication provider or your custom logic by using filter override methods and now we can override to filters on  method and  controller both. 4.       MVC 5 replaced to bootstrap by using the default template. 5.       MVC 5 added new to Att