Add Read More note with web site link When Someone Copies Text from your website.


Below code use full when you want to add your link when some one copy from your website.

Put below java script code in main Master page.

function addLink() {
    //Get the selected text and append the extra info
    var selection = window.getSelection();
    pagelink = ". Read more at: " + document.location.href;
    copytext = selection + pagelink;
 //Create a new div to hold the prepared text
    newdiv = document.createElement('div');

    //hide the newly created container = 'absolute'; = '-99999px';

    //insert the container, fill it with the extended text, and define the new selection
    newdiv.innerHTML = copytext;

    window.setTimeout(function () {
    }, 100);
document.addEventListener('copy', addLink);

Hope this will help.

Posted in | 0 comments

Format JSON Date.


Below is way to format JSON Date.

var date = new Date(parseInt(jsonDate.substr(6)));

The substr function takes out the "/Date(" part, and the parseInt function gets the integer and ignores the ")/" at the end. The resulting number is passed into the Date constructor.

if you are using newtonsoft then see at below location.

Posted in | 0 comments

How to bind Event on dynamically created elements in JQuery.

We can achieve this using jQuery.fn.on.  
(Details document available at

Let’s have an example.

Suppose your page creating element with the class name 'Applyevent'
you would bind the event to a parent which already exists
mainly 'document'

$(document).on('mouseover', '.Applyevent', function(){

    // what you want to happen when mouseover 

    // occurs on elements that match '.Applyevent'


Any parent that exists at the time the event is bound is fine. For example

$('.dynamicgenerate').on('click', 'button', function(){

    // code here


<div class="dynamicgenerate">


              <---- Dynamic Controls here ---->

              --- Suppose <button>


Posted in Labels: | 0 comments

How to remove specific session in

You can set session element to null.


Session["sessionname"] = null;

Posted in | 0 comments

How to parse html in C#?


You Can use Html Agility Pack
Details is availbale at

This is an agile HTML parser that builds a read/write DOM and supports plain XPATH or XSLT (you actually don't HAVE to understand XPATH nor XSLT to use it, don't worry...). It is a .NET code library that allows you to parse "out of the web" HTML files. The parser is very tolerant with "real world" malformed HTML. The object model is very similar to what proposes System.Xml, but for HTML documents (or streams).


using Fizzler that takes a jQuery/Sizzler approach to selecting HTML elements. It's based on HTML Agility Pack.Details available at below location.

Posted in | 0 comments

Sending mail from my gmail account through .Net

Below is sample to send mail from your gmail account.

We will use System.Net.Mail to send mail from gmail account.

using System.Net;
using System.Net.Mail;
var fromAddress = new MailAddress("", "Your Name");
var toAddress = new MailAddress("", "Receipt Name");
const string fromPassword = "YourPassword";
const string subject = "Subject";
const string body = "Body";
var smtp = new SmtpClient
    Host = "",
    Port = 587,
    EnableSsl = true,
    DeliveryMethod = SmtpDeliveryMethod.Network,
    UseDefaultCredentials = false,
    Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
using (var message = new MailMessage(fromAddress, toAddress)
    Subject = subject,
    Body = body

Posted in | 0 comments

Difference between ScriptManager and ScriptManagerProxy in

You can only have one script manager per page but you can have multiple ScriptManagerProxy.

Used ScriptManagerProxy if you have the script manager in your master for instance which will go across all pages but you want a script manager reference in an underlying page or user control. 

In that instance you would add the proxy. If you added another script manager the page would error.

Posted in | 0 comments

Run First Application in Angular 2 (Angular 2 base project).

Run First Application in Angular 2 (Angular 2 base project).

è    Need to install node.js from below location.
(Install Latest version of node.js)

è    Run below command from node.js command prompt

npm install –g @angular/cli

ng new myapp

cd myapp

ng serve

Now you will see blow output.

Now run your application from localhost:4200  (mention in above command output). You may see different output base on version.

Posted in Labels: | 0 comments

How to upgrade Node.Js to latest version

How to upgrade Node.Js to latest version.

For Linux/Max

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

Instead of stable you can also specify a desired version.

Sudo n 0.8.21

For windows

You can update npm using below command.

npm update npm -g

However to update node.js better you will reinstall from node.js website.

Posted in Labels: | 0 comments

Common Error in Angular2. Can't bind to 'ngModel' since it isn't a known property of 'input'

Common Error in Angular2. 
Can't bind to 'ngModel' since it isn't a known property of 'input'

This error you will received if you didn't included FormModule in your module.

Better way to resolve this defect is include FormModule in app.module.ts

import { FormsModule } from '@angular/forms';


  imports: [




Posted in Labels: | 1 comments

Angular 2 trigger change detection.

There are three way to implement change detection in Angular 2.

1. ChangeDetectorRef.detectChanges() 

   This is most common used.
   This will Checks only in component and its children.
   Details of class can be read at!#detectChanges-anchor

2. ApplicationRef.tick()

   It will check for full component tree.
   Details of class can be read at!#tick-anchor


   It will check the full component tree after executing the callback function.
   Details of class can be read at!#run-anchor

You can choose one method from above.

inject ApplicationRef, NgZone, or ChangeDetectorRef into your component

Hope this will be help full.

Posted in Labels: | 0 comments

Share value from one component to another component in Angular 2.


You can share value between components using Shared service.

Below is sample code for it.

in Share Service.

export class SharedService {
  private name = '';



In First Component.

  template: `
<input #myVal type="text" />
<button (click)="send(myVal.value)>Send</button>
`, }) export class FirstComponent{ constructor(service:SharedService){ this.service=service; } send(str){ this.service.saveData(str); } }

In Second Component

export class SecondComponent   {



Hope this will help you.

Posted in Labels: | 0 comments

Scroll to top of page in Angular 2 (Using routing)


Sometime we need to move on next page using clicking on page bottom link.

In Angular 2 there is a problem. Next page will not move directly to the top of the page.

This may give bad impression to end user.

Below is one way to move focus on top of the page.

register a listener of route change on main component and scroll to 

top on route changes.

Shown in below example.


import { Component, OnInit } from '@angular/core';
import { Router, NavigationEnd } from '@angular/router';

    selector: 'main-app',
    template: '',

export class MainComponent implements OnInit {
    constructor(private router: Router) { }

    ngOnInit() { => {
            if (!(evt instanceof NavigationEnd)) {
            window.scrollTo(0, 0)

You can also used document.body.scrollTop = 0. 

 Hope this will helpful.

Posted in Labels: | 0 comments

Generate Guid In Angular 2 Application (type Script)

Generate Guid In Angular 2 Application (type Script)


Below is code block to generate GUID in angular 2 application.

 function newguidgen() {  
  function id() {  
   return Math.floor((1 + Math.random()) * 0x10000)  
  return id() + id() + '-' + id() + '-' + id() + '-' +  
   id() + '-' + id() + id() + id();  

Posted in Labels: | 0 comments

Could not load file or assembly 'system.web.http' or one of its dependencies. The located seembly's manifest definition does not match the assemblr reference (Exception from HRESULT : 0x80121040)


Sometime we receive below error message.

Could not load file or assembly 'system.web.http' or one of its dependencies. The located seembly's manifest definition does not match the assemblr reference (Exception from HRESULT : 0x80121040)

Solution :-
It will be fix with reinstall of Package.
Run below command in Package manager.

Update-Package Microsoft.AspNet.WebApi -reinstall

Posted in | 2 comments

Error in Upgrade of Node.JS


Below is command use to upgrade node.js.

npm install npm@latest -g  (Upgrade node.js)

Sometime we get the error in upgrade like

In most of cased the problem with Proxy setting.

To check proxy try to access below url.

if it works then your proxy is fine else some problem with proxy.

After resetting my proxy it's work fine.

Hope this will helpful..


Posted in Labels: | 0 comments