Thursday, 17 September 2015

What is Different Between Jquery & JavaScript?

JQuery is a framework for writing javascript tasks in a easier way. JQuery it is written in javascript. Also, I should mention that browsers parse only html and css files as also js scripts. Hence, all javascript frameworks (jQuery, AngularJS, etc) are written in javascript. They provide you the oportunity to write js code easier but under the hook they are all written in javascript.
An example in order to understand why JQuery is easier.
Say we have the following input element

<input id="button1" type="button" value="clickMe"/>

Also say that we want when someone click on the button to have an alert box showing to the user a 'Hello' message.Then the code in javascipt would be:-

document.getElemementById("button1").addEventListener('click', function(){
    alert("Hello");
});

Using JQuery the above would be written as follows:

$('#button1').click(function()
{ 
alert("Hello"); 
});

Using JQuery makes things more clear. (write less do more is jQuery's moto)

So jQuery is "Write Less,Do more"...
Happy Coding...



Tuesday, 4 August 2015

What Is Scaffolding?

Scaffolding in ASP.NET MVC can generate the boilerplate code you need for create, read, update, and delete (CRUD) functionality in an application.

How it Work?


  1.  The scaffolding knows how to name controllers, how to name views, what code needs to go in each component, and where to place all these pieces in the project for the application to work.
  2.  Scaffolding runs only when you tell it to run, so you don’t have to worry about a code generator overwriting the changes you make to the output files.

A variety of scaffolding templates are available in MVC 5.The following sections highlight a few of the available templates.

1. MVC 5 Controller:-
Empty The empty controller template adds a Controller-derived class to the Controllers folder with the name you specify. This template will not create any views.

2. MVC 5 Controller with read/write Actions:-
 The read/write actions template adds a controller to your project with Index, Details, Create, Edit, and Delete actions. The actions inside are not entirely empty, but they won’t perform any useful work until you add your own code and create the views for each action.

3. Web API 2 API Controller:
 Scaffolders Several templates add a controller derived from the ApiController base class. You can use these templates to build a Web API for your application. 

4. MVC 5 Controller with Views, Using Entity Framework :-
This template is the template you’ll use to scaffold the store controller. This template not only generates your controller with the entire suite of Index, Details, Create, Edit, and Delete actions, but also generates all the required views and the code to persist and retrieve information from a database.


Happy Coding..




Thursday, 30 July 2015

What is MongoDB and Why to use it?

MongoDB is one of the most popular open-source NoSQL database written in C++. As of February 2015, MongoDB is the fourth most popular database management system. It was developed by a company 10gen which is now known as MongoDB Inc.



MongoDB is a document-oriented database which stores data in JSON-like documents with dynamic schema. It means you can store your records without worrying about the data structure such as the number of fields or types of fields to store values. MongoDB documents are similar to JSON objects.



Happy Coding !!


Introduction to ASP.NET vNext and MVC 6

Microsoft has announced the next generation of ASP.NET at TechEd North America on 12 May 2014, which is called ASP.NET vNext. ASP.NET vNext includes new cloud optimized versions of MVC6, Web API3, Web Pages4, SignalR3 and Entity Framework7.

Features of ASP.NET vNext
  1. ASP.NET vNext includes new cloud-optimized versions of MVC, Web API, Web Pages, SignalR, and Entity Framework.
  2. MVC, Web API and Web Pages have been merged into one framework, called MVC 6. This will follow common programming approach between all these three i.e. a single programming model for Web sites and services.
For example, there is unified controller, routing concepts, action selection, filters, model binding, and so on. In this way, You will have a single controller that returns both MVC views and formatted Web API responses, on the same HTTP verb.


  1. MVC 6 has no dependency on System.Web since it was quite expensive. A typical HttpContext object graph can consume 30K of memory per request and working with small JSON-style requests this is very costly. With MVC 6 it is reduced to roughly 2K. The result is a leaner framework, with faster startup time and lower memory consumption.
  2. ASP.NET vNext has new project extension project.json to list all the dependencies for the application and astartup class in place of Global.asax.
  3. ASP.NET vNext apps are cloud ready by design. Services such as session state and caching will adjust their behavior depending on hosting environment either it is cloud or a traditional hosting environment. It uses dependency injection behind the scenes to provide your app with the correct implementation for these services for cloud or a traditional hosting environment. In this way, it will easy to move your app from on-premises to the cloud, since you need not to change your code.
  4. .NET next version, .NET vNext is host agnostic. Hence you can host your ASP.NET vNEXT app in IIS, or self-host in a custom process.
  5. .NET vNext support true side-by-side deployment. If your app is using cloud-optimized subset of .NET vNext, you can deploy all of your dependencies including the .NET vNext (cloud optimized) by uploading bin to hosting environment. In this way you can update your app without affecting other applications on the same server.
  6. Dependency injection is built into the framework. Now, you can use your preferred IoC container to register dependencies.
  7. .NET vNext use the Roslyn compiler to compile code dynamically. Hence you will be able to edit a code file and can see the changes by refreshing the browser; without stopping or rebuilding the project.
  8. .NET vNext is open source and cross platform. It can run on Mono, on Mac and Linux.
Happy Coding...

What's the difference between ViewData and ViewBag?

  1. ViewData
  • ViewData is a dictionary of objects that is derived from ViewDataDictionary class and accessible using strings as keys. 
  •  ViewData requires typecasting for complex data type and check for null values to avoid error
  • Example:

    public ActionResult Index()
    {
    ViewData["Name"] = "Dhiren Web developer";
    return View();
    }
     2. ViewBag

  • ViewBag is a dynamic property that takes advantage of the new dynamic features in C# 4.0. 
  •  ViewBag doesn’t require typecasting for complex data type.
  • Example:
              public ActionResult Index()
           {
                      ViewBag.Name = "
Dhiren Web developer";
                      return View();
            }

Calling in View

@ViewBag.Name
@ViewData["Name"]

Happy Coding...

Picking between Xamarin and Apache Cordova


 Xamarin is generally better when you:
  • Need to do apps with less shared UI, more shared logic. Xamarin.Forms changes this, but it’s still very new at the moment
  • Have .Net developers
  • Need a high performing, native looking app
Cordova with Visual Studio is generally better when you:
  • Want to share more UI between platforms, with fewer native looking elements.
  • Share UI assets with a mobile websit
  • Have HTML \ JS developers
  • Are OK with a somewhat less smooth UI on older Android and iOS devices, or don’t plan on supporting older Android (pre 4.2)
The Xamarin experience for developers is generally better than the
Cordova experience, having been around a bit longer. Cordova can be really
difficult if you don’t use the new Visual Studio integration.

Xamarin has a license cost, Cordova does not. However, the difference in
the license cost can quickly be eaten up by having to do more work to account
for different Android versions on a Cordova app.

Xamarin has a much greater need for access to a Mac while developing iOS
apps than Cordova. Cordova apps can be built against an iOS
emulator running in Chrome
. You absolutely still have to do testing against
physical devices.

My preference is usually for Xamarin, but there are situations that are
better suited to Cordova-based apps. I wouldn’t do Cordova apps without the new
Visual Studio support.

I’m finding more and more services companies using Xamarin, and more
startups using Cordova. Services companies can quickly recover the Xamarin
license cost through improved productivity, whilst startups have a need to keep
costs down, whilst being real responsive to changes in their product on
multiple platforms, including the web.

Happy Coding !! Enjoy

See You Soon...