Skip to main content

Posts

Showing posts from February, 2016

Use of MVC ViewBag List Items in Razor for-each loop

MVC  Razor for-each loop with   ViewBag List Items and t he code-sample for the r azor for-each loop with respect to the  ViewBag. @ foreach ( var employee in (( List < Employee >)ViewBag.Employees)) {     < span > @ employee.EmployeeCode </ span >     < span > @ employee.Name </ span > } Thank you!

MVC Razor get the previous Year, Month and Days using ASP.NET

Code sample for Previous Year DateTime lastYear = DateTime .Now.AddYears(-1); Code sample for Previous Month DateTime lastMonth = DateTime .Now.AddMonths(-1); Code sample for Previous Day's DateTime lastDays = DateTime .Now.AddDays(-1); Thank you!

JavaScript onkeypress event to a Textarea

HTML code-sample < textarea type ="text" onkeypress ="postComment(event, this);" rows ="4" placeholder ="Type your comments"></ textarea > JavaScript code-sample < script type ="text/javascript">     function postComment(event, item) {         if (event.keyCode == 13)         {             //TODO: your logic.         }    } </ script > Thank you!

Auto logout in Angularjs, based on idle user

Ng-Idle : - The Angular “ NgIdle ” are used to detecting and responding to idle users and it automatically handles the Auto logout process. Why use Auto Logout in Angular 1 or Angular 2? 1.      A user must be logged out after 10 to 15 minutes (As per you). 2.      Every click interaction must reset the timer. 3.      The timer must be synchronized between tabs and so on. 4.      If users close the tab before your timer expires, he gets logged out when he visits again. Stayed Informed - Angular 2 auto logout! The Example 1 - Auto logout based on idle user as, Step 1: - First you go on  Google CDN Server  and download the angular.js file and angular-idle.js on your local and setup in your apps. < script src = "angular.js" >< /script> < script src = "angular-idle.js" >< /script> Step 2:- var app = angular.module( ‘ myApp ’ , [ ‘ ngIdle ’ ]); Step 3:- app.config([ "KeepaliveProvider&quo

How to add a browser tab icon for a website?

Hello everyone, Today I am going to share to display the browsers tab icon in my MVC 5 cloud applications. We can use the below code and put MVC layout page header section with your valid image icon path. < link rel =" shortcut icon " href ="~/images/icon.png"> I hope you enjoyed this line of code-sample. Please send me feedback for the same. Thank you!!

What is AngularJs isDefined() Function?

The angular isDefined () function is  use to check the value or references in defined or not in angular $scope. If the  value or reference is  defined then return the true otherwise  return   false. The live demo, click on link http://embed.plnkr.co/Cp2KA2/ Syntax :                    angular.isDefined($val);       The isDefined() function is case sensitive and takes a $val and returns true/false. JavaScript Code :        var app = angular.module( 'myApp' , []);         app.controller( 'myCtrl' , [ '$scope' , function ($val) {             $val.welcomeMsg = function () {                 if (angular.isDefined($val.message)) {                     $val.lblmessage = 'Welcome you  ' + $val.message + '!' ;                 } else {                     $val.lblmessage = 'Please enter your name' ;                 }             }         }]); The example in detail as give below < !DOC

Angular 2 vs AngularJs

What are major changes in Angular 2? Integration of Angular 1 and Angular 2 Why Angular 2? New Features of Angular 2 First app with Angular 2 and ES6 Forms in Angular 2 ng-for loop in Angular 2 example What is ECMAScript ES6? What is Traceur compiler? Thank you!

Convert nvarchar to uniqueidentifier in SQL Server

Create function for   convert nvarchar to uniqueidentifier as given below. ALTER FUNCTION [dbo] . [Str2Uniqe] ( @s VARCHAR ( 50 )) RETURNS UNIQUEIDENTIFIER AS BEGIN     SET @s = REPLACE ( REPLACE ( @s , '0x' , '' ), '-' , '' )     SET @s = STUFF ( STUFF ( STUFF ( STUFF ( @s , 21 , 0 , '-' ), 17 , 0 , '-' ), 13 , 0 , '-' ), 9 , 0 , '-' )     RETURN CAST ( @s AS UNIQUEIDENTIFIER ) END Select created function result as given below. DECLARE @guid VARCHAR ( 50 ) SET @guid = '3b8766fa720043af9e21c5bc6bbbdea5' SELECT dbo . Str2Uniqe ( @guid ) Result as given below.

Concepts of Build, Rebuild and Clean Application

Build Solution When we build an application using Visual Studio that time it will build only those files which have changed/modified.  The files which are not changed/modified Will not build. Clean Solution The clean  solution are use to delete all the compiled DLLs and EXE files from bin/obj  application directories. Rebuild Solution When we Rebuild  an application using Visual Studio that time deleted all complied like DLLs and EXE files and after that build all the files which are changed/modified or not. It is a combination of both clean and Build. i.e. ( CLEAN + BUILD )

SQL Server uniqueidentifier GUID auto generated

--CREATE TABLE USING AUTOINCREMENT UNIQUEIDENTIFIER . CREATE TABLE [DBO] . [GUID_DEMO] (                 [ID] [BIGINT] IDENTITY ( 1 , 1 ) NOT NULL,                 [GUIDS] [UNIQUEIDENTIFIER] NOT NULL,                 [EMPID] [NVARCHAR] ( 20 ) NOT NULL,                 [EMPNAME] [NVARCHAR] ( 255 ) NOT NULL ) ON [PRIMARY] GO    ALTER TABLE [DBO] . [GUID_DEMO] ADD   CONSTRAINT [DF__GUID_DEMO__GUIDS__058EC7FB]   DEFAULT ( NEWID ()) FOR [GUIDS] GO --INSERT ROWS VALUES IN THE TABLE. INSERT INTO [DBO] . [GUID_DEMO] ( [EMPID] , [EMPNAME] ) VALUES ( 'VIA01' , 'ANIL SINGH' ) INSERT INTO [DBO] . [GUID_DEMO] ( [EMPID] , [EMPNAME] ) VALUES ( 'VIA02' , 'SUNIL SINGH' ) INSERT INTO [DBO] . [GUID_DEMO] ( [EMPID] , [EMPNAME] ) VALUES ( 'VIA03' , 'SUSHIAL SINGH' ) INSERT INTO [DBO] . [GUID_DEMO] ( [EMPID] , [EMPNAME] ) VALUES ( 'VIA04' , 'ARADHYA SINGH' ) INSERT I