Wednesday, May 27, 2015

Disable Browser Link on Visual Studio 2013

The Browser Link controls are located in the dropdown with the circular arrow icon. The arrow icon is the Refreshbutton.

 

Tuesday, May 26, 2015

ASP.NET MVC:How to pass the object from Filter to Controller method

     Consider request caching for persist the values on each http request. So store the object  in                       HTTPContext.item  and read the object from  HTTPContext.Item.  
Make sure that store  necessary properties on view in hidden fields . ASP.Net model binding will construct the  object from the view so that we no need to re build the object every time.

<![if !supportLists]>1.       <![endif]> On filter store the values
public override void OnAuthorization(AuthorizationContext filterContext)
{     
UserViewModel userviewModel =  new UserViewModel()
//load the properties using some service…           
filterContext.RequestContext.HttpContext.Items["UserViewModel"] = object;
}
<![if !supportLists]>2.  <![endif]>On controller read the object from HTTPContext
UserViewModel userviewModel =    HttpContext.Items["UserViewModel"as UserViewModel

Tip : How to copy the data between two object.

 

       Actually we may come across the scenario that we need to copy the properties form View model object to actual model object .

       Instead of coping each property from source to target , Consider serialization to copy the data from source to target.

       Serialize the source object into JSON string and Desterilize the JSON to target object.

       Example:

1.         var serilize = new JavaScriptSerializer();

    

      public class SourceModel

      {

        public int id { get; set; }

        public System.DateTime start_date { get; set; }

       public System.DateTime end_date { get; set; }

      }

     

2.       SourceModel sourceobj =  new SourceModel();

 

     public class TargetModel

    {

        public int id { get; set; }

        public System.DateTime start_date { get; set; }

       public System.DateTime end_date { get; set; }

         .

         .

         .  

    }

3.       var json = serilize.Serialize(sourceobj);

4.       var targetModel =  serilize.Deserialize<SessionViewModel>(json);

 

                  NameSpace:  System.Web.Script.Serialization

How to connect to TFS

1)      Open Visual studio and click on TFS

2)      Select click on connect to TFS

 

3)      Click on server and Click on Add server name

Monday, May 25, 2015

Create and Install Node

Install Node.js.
      Required programs:
                           1)      Node: Node is platform to build scalable web application. Node.js  downloaded from  https://nodejs.org/
                             2)      Express: Express is framework for node.js to build web application.
                             3)      Node package manager: Install, publishes and manages Node Programs.
                             4) Notepad++
Steps:
1)      Down load node from https://nodejs.org/.
2)      Click and follow the instructions.
3)      Node installs node package manager.
4)      Open command prompt and verify after installation.
5)      If it is windows 8 reboot the machine
6)      Type NPM in command prompt and verify npm is successfully installed on the system.
                             




Create First program

             1)  Create folder Node Services
             2)  Use npm init to create application
             3)  Give name as studentapi  and click until end of all options
             4)  Install Express using node install express --save
                     "--save"option  will save the package into the package folder. 
              5) Create app.js file.
              6)