Friday 3 June 2016

Difference Between MVC and webforms


The main advantages of The Official Microsoft ASP.NET Site MVC are:
  • Enables the full control over the rendered HTML.
  • Provides clean separation of concerns(SoC).
  • Enables Test Driven Development (TDD).
  • Easy integration with JavaScript frameworks.
  • Following the design of stateless nature of the web.
  • RESTful urls that enables SEO.
  • No ViewState and PostBack events
  • SEO friendly URL by design
  • No ViewState (this may seem a bit of moving backward to some), but overall a good design
    decision
  • Clean View Markup (no additional HTML emitted)
  • 100% extensible. You can add your own controller with IOC, switch view engines at will, control model binding at wish etc
  • Rich UI support (possible through client side JS libraries like jQuery UI and others)
  • Pluggable architecture
  • Out of the box minimal IOC support
  • Out of the box support for mitigating antiforgery attacks and XSS vulnerability
  • MVC is Faster by default because of lack of viewstate and clean markup. But performance is subject and MVC by design is more performant that traditional The Official Microsoft AspDotNet webforms
Limitation of MVC 
  • There is little Bit Long Learning Curve as compared to Asp.Net webforms 
The main advantage of Aspdotnet Web Form are:
  • It provides RAD development
  • Easy development model for developers those coming from winform development.

Difference Between MVC and webforms

Monday 23 May 2016

Abstract Class vs interface in Csharp


Abstract Class
Abstract Class is a class that is used as a base class and contains common methods that can be defined by class that inherits from this Base Class .  We can only inherit abstract class But We cannot instantiate Abstract Class . Abstrac classes contains both incomplete & complete methods . Means it can contains functions with definitions as well as abstract methods with only declarations . It can also contains Data Members along with subs , propreties and methods .

Interface :
Interfaces Contains only Declaration / Signature of Functions and does not contains definition of functions . Unlike Abstract classes Interfaces cannot contain complete methods or methods with definition it only contains signature of methods means only declarations
Interface also supports multiple inheritance that is not supported by Abstract classes

Difference Between Abstract Class and Interface -


Abstract Class
1. Abstract Class Can Contain Complete (functions with definitions) or Incomplete(Abstract) Members
2. Abstract Class cannot be instantiated
3. Abstract Class Can contain Data members
4. Abstract Class Can have Constructors . We Can Have Parameterized Constructors also in Abstract Class

Example :-
public abstract class ABC
{

int _a;
   
  //Parameterized Abstract Class Constructor
  public ABC(int a)
  {
    _a = a;

   }

  //Default Constructor
  public ABC()
  {
   // Code Logic

   }
public abstract void computeA(); };
public class Foo : ABC
{
    // Always pass 123 to the base class constructor
    public Foo() : base(123)
    {
    }
}
5. Incomplete members of Abstract class Means Abstract Members are Virtual Means it can be overridden by Derived Members
6. Abstract Members Cannot be Static
7. Complete Members Can be Static
8. Abstract Members can use Access Specifiers

All Private , Protected and Public Access Specifiers can be used with Abstract Class Methods . Purpose of Create Private Methods in Abstract Class is similar to normal class . These methods are used by other public methods of Abstract class as we know we can also define methods in abstract class.

Interface
1. Interface Can only Contain only Incomplete Methods that means methods with only Declaration without any definition
2. Interface cannot be Instantiated
3. Interface cannot contain data members
4. Interface cannot have constructors
5. there is no virtual member in interface as we cannot provide definition of member function in interface only inheriting class can define that function
6. Interace Cannot have Static Members
7. Complete Member does not exist in Interface
8. Interface member are public and we cannot set any access modifier to interface members

Sunday 22 May 2016

Difference Between Generic and Collections in C#


Difference Between Array - Generic - Collections in Csharp

Array :

An Array is Fixed Size Data Type . For Storing data in Array you need to define the size of array and Also Type of Array ( int, string , float etc )

Depending on Memory Allocation Data Types are of Two Types -

  • Value Type 
  • Reference Type 

See Difference Between Value Type and Reference Type in Link Below - 
http://geeksprogrammings.blogspot.in/2015/09/value-types-vs-reference-types-dotnet.html

Array is a Value Type that needs to define its size in order to allocate space to it in memory . This is little problem with array as sometimes we need Dynamic Size to store large number of values

Collections :
Collections are Defined in System.Collections Namespace . Collections Are Variable Sized . We Can add / remove items from collection with any restriction of defining size and type of data

Example :- Arraylist are Collections .

Logically Collections are Referency Types . Now Question is Why Collections are Referencec Types ?

Collections are of Variables Sized So Whenever Some Type is Variable Sized It needs to be stored in head instead of Memory Stack give to application . and poiter to that heap is set in the top of stack . it is stored in heap because main memory is valuable and we don't exactly know that How much size variable sized Collection will take so it is allocated disk space as heap instead of storing it directly in main memory Pointer to heap location is set to top of stack so whenever we require it we can use that pointer to get / set that value .

See Difference Between Value Type and Reference Type ( Stack & Heap ) in Link Below - 
http://geeksprogrammings.blogspot.in/2015/09/value-types-vs-reference-types-dotnet.html

Example of Collections - 

ArrayList arrList = new ArrayList();
arrList.Add(007);
arrList.Add("Heemanshu Bhalla");
arrList.Add(DateTime.Now);

If we want to loop that arrList then we can do it as below -

foreach (object o in arrList)
{

}

But there is one problem we always need to parse each element in collection using object as we don't know the type of data that it contains and that could create problem on runtime

Problem With Collections & Evolution of Generics

Generic Types Solves This problem check Generic Types Below  -

Generic Types :
Generic Types Contained in System.Collections.Generic Namespace . It removes the problem of Unknown Data types exist in Collections

Generic List ( List <T> ) , Here T means datatype that could be Int , String , DateTime etc . So We can define the type of data that we want to store and we can also parse the data simple as type is already known . SO it is Type Safe . If you Create Int Generic List or Generic Type and try to store some different type then it will give compilation Error and does not allow you to store data of Another Type that is not allowed .

Example of Generic List below - 

List<string> lstString = new List<string>();
lstString.Add("Heemanshu Bhalla");
lstString.Add("I am A Geek");

List<int> lstInt = new List<int>();
lstInt.Add(007);
lstInt.Add(786);

Saturday 21 May 2016

Convert Date Format To dd/mm/yy in Sql Server


If you Mssql Server is Using Some Other Date Format For Insert Date in Date Column Then Possibly Default Date format is set to US Date Format ( mm/dd/yy ) and if you want to insert date in dd/mm/yy . In order to insert date in this format you need to set Date Format to French / British ( dd/mm/yy )

So first I recommend you to Use any of Jquery Date Picker and pass the selected date / datetime as below to Insert Query as Below -

insert Table_Name (Date_Column)  values (convert(datetime,'18-06-12 10:34:09 PM',103));

Here second parameter 103 is For French Date Format dd/mm/yyyy .If you want to have dd/mm/yy then use 3 in that parameter

Different Types of Date Format Code as As Below - 

Without century (yy) (1)With century (yyyy)StandardInput/Output (3)
-0 or 100 (1,2)Default for datetime and smalldatetimemon dd yyyy hh:miAM (or PM)
1101U.S.1 = mm/dd/yy

101 = mm/dd/yyyy
2102ANSI2 = yy.mm.dd

102 = yyyy.mm.dd
3103British/French3 = dd/mm/yy

103 = dd/mm/yyyy
4104German4 = dd.mm.yy

104 = dd.mm.yyyy
5105Italian5 = dd-mm-yy

105 = dd-mm-yyyy
6106 (1)-6 = dd mon yy

106 = dd mon yyyy
7107 (1)-7 = Mon dd, yy

107 = Mon dd, yyyy
8108-hh:mi:ss
-9 or 109 (1,2)Default + millisecondsmon dd yyyy hh:mi:ss:mmmAM (or PM)
10110USA10 = mm-dd-yy

110 = mm-dd-yyyy
11111JAPAN11 = yy/mm/dd

111 = yyyy/mm/dd
12112ISO12 = yymmdd

112 = yyyymmdd
-13 or 113(1,2)Europe default + millisecondsdd mon yyyy hh:mi:ss:mmm(24h)
14114-hh:mi:ss:mmm(24h)
-20 or 120 (2)ODBC canonicalyyyy-mm-dd hh:mi:ss(24h)
-21 or 121 (2)ODBC canonical (with milliseconds) default for time, date, datetime2, and datetimeoffsetyyyy-mm-dd hh:mi:ss.mmm(24h)
-126 (4)ISO8601yyyy-mm-ddThh:mi:ss.mmm (no spaces)

Note: When the value for milliseconds (mmm) is 0, the millisecond value is not displayed. For example, the value '2012-11-07T18:26:20.000 is displayed as '2012-11-07T18:26:20'.
-127(6, 7)ISO8601 with time zone Z.yyyy-mm-ddThh:mi:ss.mmmZ (no spaces)

Note: When the value for milliseconds (mmm) is 0, the milliseconds value is not displayed. For example, the value '2012-11-07T18:26:20.000 is displayed as '2012-11-07T18:26:20'.
-130 (1,2)Hijri (5)dd mon yyyy hh:mi:ss:mmmAM

In this style, mon represents a multi-token Hijri unicode representation of the full month's name. This value will not render correctly on a default US installation of SSMS.
-131 (2)Hijri (5)dd/mm/yyyy hh:mi:ss:mmmAM

Evolution of Javascript To Jquery To AngularJS


Today’s starting programmers mostly directly dive into Jquery / angularjs , Programmers of last decade started with javascript . and Now Angularjs is on hike .

See whenever a WebPage is opened , JS / Jquery / AngularJS Code is on Client Side So Amount of Code is adds to Page will Increase Request Time .

We Use Javascript Before Jquery , Different types of Sliders , Dom Manipulations were done with lot of Javascript code like using But After Jquery We took a Relief for many things as below
Lines of Code Decides Lifeline of App as below -

Javascript -
Function changeBachground(color) {
  Document.body.style.background = color;
}
Onload=”changeBackground (‘red’);”

Jquery 
$ (‘body’) .css (‘background’, ‘#ccc’);

So Simple if we can achieve something easily with less code why we will not adopt it 
Then AngularJS Came that is a complete MVC Framework . It is also Javascript Framework . So whatever you do with AngularJS you can also achieve with Javascript . But Why you need to it start it from scratch you can join angularjs repository to propose some solid changes to it and extend it if you strongly need as doing everything you need to do in a website using javascript doesn’t look good idea .

JAVASCRIPT CODE

Characters: 700

Lines of JavaScript: 13
<!DOCTYPE html>
<html>
  <body>
    <h1>Hello World with pure JavaScript</h1>
    Write some text in textbox:
    <input id="hello-input" type="text" />
    <h2 id="hello-output">Hello </h2>

    <script>
      var inputField = document.getElementById('hello-input');
      var label = document.getElementById('hello-output');

      var handleKeyup = function() {
        var value = inputField.value;
        label.innerHTML = 'Hello ' + value;
      }

      if (document.addEventListener) {
        document.addEventListener('keyup', handleKeyup);
      } else if (document.attachEvent) {
        document.attachEvent('keyup', handleKeyup);
      }
    </script>
  </body>
</html>

JQUERY

Characters: 529
Lines of JavaScript: 7
<!DOCTYPE html>
<html>
  <body>
    <h1>Hello World with jQuery</h1>
    Write some text in textbox:
    <input id="hello-input" type="text" />
    <h2 id="hello-output">Hello </h2>

    <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
    <script>
      var inputField = $('#hello-input');
      var label = $('#hello-output');

      inputField.on('keyup', function() {
        var value = inputField.val();
        label.html('Hello ' + value);
      });
    </script>
  </body>
</html>

ANGULARJS

Characters: 325
Lines of JavaScript: 0
<!DOCTYPE html>
<html ng-app>
  <body>
    <h1>Hello World with AngularJS</h1>
    Write some text in textbox:
    <input type="text" ng-model="sometext" />
    <h2>Hello {{sometext}}</h2>

    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
  </body>
</html>

Wednesday 18 May 2016

Namotel : Make In India Failed Again


The Story of Freedom 251 is not so old and Now Again Make In India Came With a New Crappy Thing "Namotel"  . We know Namo is rocking these days in Indian Politics But that does not mean its name works everywhere . If you are doing Shit then It will not come in different way if you say NAMO .

Namo + tel  = Website Crash

Namotel is another attempt of "Make In India" To Lauch & Offer Chepest SmartPhone . The Crappy game started by Freedom 251 gave to birth to another one . This Time SmartPhone is offered at Price of "Rs 99" It is claimed to be India's Most Affordable Smartphone

In Press Conference Company's Promoter Madhav Reddy Said Smartphone will be available to be booked at Price of Rs99 from 17 May,2016 To 25 may, 2016 On Company's Official Website Namotel . Smart Phone Will Be Available on Cash On Delivery

But I think they Don't Know How To Launch A Product To 1.252 Billion Indians . This Also Doubt About the Quality of Make In India Products That they are planning To launch and also Some That they launched .

Instead of Launching Cheap SmartPhone they should Use Their Talendted People To Make Valuable , Creative and Better Quality Product Atleast Better Than Freedom 251 or Nametel

Message By Comapany That Didn't Stood Up For Even 1 Day

 'Joy and freedom represents the logo! The same joy will flourish in billion Indians in the form of smart Connect with (3 different looks and shapes) Android Smart powerful Phone at 99. We make this product to show love for India it is a 'MAKE IN INDIA' Initiative. This model is limited and it is applicable only for India and who holds Aadhar Identity.'

Namotel Rs. 99 SmartPhone Product Specification


  • 4-inch display with 480x800 pixels WVGA resolution.
  • Android 5.1 Lollipop OS 
  • 1GB RAM. 
  • 4GB of internal storage which is expandable up to 32GB via microSD card.
  • 2MP camera at the back and a VGA selfie camera
  • Connectivity options include 3G and dual-SIM.
Different Namotel Products







COMPANY WEBSITE BELOW




Tuesday 17 May 2016

Tempdata vs Session in Asp.net MVC


Why Sessions are Not Recommended to use in MVC

One of the Fundamental Principal of Asp.Net MVC Framework is  Web is Stateless And AspDotNet MVC is Stateless AspDotnet WebForms is a try to make Stateful Modal But Its difficult to main it as this modal does not exist . Sessions Create lot of load on Cache that was biggest problem .

Using Session in AspDotNet MVC is like Putting APPLE Logo on Asus Laptop and Calling it Apple Laptop . Reality does not change .

What Is Alternative To Session in MVC

You can use TempData in place of Session . Tempdata is limited form of Session . Don’t Use Session in MVC as you are already having Tempdata and one benefit of Using Tempdata is They will automatically deleted no need to clear or remove them as we do with session

How To Use TempData In MVC

When Data is TempData is read it is immediately market for deletion at the end of request . That means you can use Value Tempdata In Tempdata Only at the Next Request . See Example Below - 

TempData is Filled With Data

TempData["SomeTemp"]= "Hey! This is MVC" ;

Tempdata Accessed in Second Request 

Object value = TempData["SomeTemp"] ;

Value in Tempdata will be Cleared After Above Line of Code . If you access in after that line of code after above line you will not found it there it will be deleted


Keep And Peek Methods 

Peek And keep methods are used to read value without marking it for deletion after reading its value . So it is acutally helping us to retain its after its first read instead of deleting tempdata

With Peek Method We get the value of Tempdata Without Marking it For Deletion . In this method we access the Tempdata value using Peek Method That tells it to Hold Value and does not mark it for deletion

With Keep Method we hold the Value of Tempdata that was marked for Deletion after its  first read . so it is using two different calls . First one is getting Tempdata Value then Second call is To Save Tempdata From Deletion

Saturday 14 May 2016

Which is a more valuable skill in freelancing Web Development or Web Designing


Quality Of Work is Valuable in Freelancing , Along with Dedication to work , Punctuality , Quick and Efficient Decision Making & Logical Thinking etc .
If we go for Comparing Designer With Web Developer To know which one is more valuable Then I think the Comparing them makes no sense . Its like comparing Michael Jordan To Lionel Messi . So we Should . They both are from sports but we can’t compare them Both have their own games and requires different view of thinking
Both Skills are Important Part of Project . There was Time When Functionality of Website was thing that was needed in website & Design of Website was not crucial But In Today’s World Along with Functionality of Website Design , User Usability are important aspects of website .
Only Making website to look pretty is not enough In Web Designing . It should be good according to User Usability Rules , It should be Responsive to different available Screens , Performance of Page loading is also included for web designer .
I Know Web Development project lasts long as compared to some of the Web Designing Projects That’s make more person attracted to them for more earning . But Creativity has No Money Bar . If you require a Unique Web Design or Logo etc Then That may cost you more than a Web Development Project . Developing Creative Gif’s for your Business / Ads Purposes are Very Creative & Demanded Things .
There are Number of Online Website including ThemeForest ,Templatemonster , colorlib, freshdesignweb etc . These Websites Contains number of Contributions From Developers .
Web Development is regarding to working / Logical Making of website So that consumes your more time . So Other Person is not hiring you , Client is hiring your Time So More Time is consumed in Web Development That’s Why Web Developers Sometime Earns More and This Thing attract most person to go in web development
All In All We Can both web development & Web Designing Have their own Importance . All That Maters is How good you are in your Skill & Quality of work .
All The Best Feel Free to share your Views

Thursday 12 May 2016

Create News Feed In PHP


Code To Create A Simple News Feed In PHP


Use Ajax & Jquery To Fetch & Populate News Feed . Make Ajax Call From Page Control Will go to specified PHP page through ajax call then fetch data in that PHP page and send data to callback to Ajax Call

See A simple Example below :-

HTML PAGE CODE

<html>
<head>
//Required CSS  / JSS Files
</head>
<body>
<div id="news"></div>
//Click Button Below To Fetch News Feeds
<input type="button" onclick="GetNews()" value="Get News Feed" />
<script>
    function GetNews()
    {
        $("#news").load("path_to/AjaxFetchData.php")
    }
</script>
</body>
</html>


AjaxFetchData.php File Code


//Sql Query To Fetch News Feed From Database
$con= Initialize it with connection Details for database
$sql = "Select Top 50 from TblNews";
$result = $result=mysqli_query($con,$sql);
while($row =  $result->fetch_assoc())
{
    echo("<div class='NewsFeed'>");
    echo("<div class='title'>" . $row['title'] . "</div>");
    echo("<div class='body'>" . $row['body'] . "</div>");
    echo("</div>");



}

Does domain extension affect seo



Impact Of Domain Extension On Seo And Business Success


What Do you Think Does Domain Extensions Make Any Effect on SEO of Website . Everybody First tries to get '.COM' Extension and other extension like .info , .in etc are not liked so much .

What Do you think does domain extension put any effect on Optimization of Your Content on Search Engines .

There are neither any penalties Nor any preferences is given for Domain Extensions By google.com . All Domain Extensions are treated equally in agoogle.com web search.
However, Domain Extension do affect your search results for country specific searches. For example, a .co or .in domain will not rank as well as a .us website in a google.us web search. Also, a .co.uk site will rank better then a .us site in a google.co.uk search. 
So In Above Cases Domain Extensions have an Impact on Search Result and SEO . But Otherwise there is no inbuilt Algorithm in Search Engines That Filter Or give preference to Some Specific Domain Extension
So if you are targeting a specific country or region, try to use the Domain Extension for that country or region. If not then the TLD does not make a difference

If .COM is Not Available Then What Should We Do ?

I think the best advice in think kind of situation is to search for a different domain name, especially if the .com is owned by a competitor in your space (you can also face some legal issues in future ). 

Domain Extension Preferences :

  • If you are targeting your Product in Specific Country then Go for Domain Extension Specific to That Country Like if you are targeting United States The it good to choose .US Extension
  • If you are planning a Non-Profit Organisation Then you can choose .ORG
  • Other wise For All purposes Choose .COM Extension 

As Joel Spolsky Said - .COM Extensions are Million Times Better Than Other Extensions





How Twitter Bootstrap Works


Twitter Bootstrap is very well known CSS framework today . It is easy to Use CSS framework that helps in Creating Responsive Web pages . I am going to give a Brief Overview of How Bootstrap Differentiate between Different Screen Sizes

Bootstrap includes a responsive, mobile first fluid grid system that appropriately scales up to 12 columns as the device or viewport size increases. It includes predefined classes for easy layout options, as well as powerful mixins for generating more semantic layouts.

Media queries

Bootstrap Uses Media Queries To Differentiate Between Screen Sizes . See Below What is code behind these media queries

/*==================================================
= Bootstrap 3 Media Queries =
==================================================*/
/*========== Mobile First Method ==========*/
/* Custom, iPhone Retina */
@media only screen and (min-width : 320px){
}
/* Extra Small Devices, Phones */
@media only screen and (min-width : 480px){
}
/* Small Devices, Tablets */
@media only screen and (min-width : 768px){
}
/* Medium Devices, Desktops */
@media only screen and (min-width : 992px){
}
/* Large Devices, Wide Screens */
@media only screen and (min-width : 1200px){
}
/*========== Non-Mobile First Method ==========*/
/* Large Devices, Wide Screens */
@media only screen and (max-width : 1200px){
}
/* Medium Devices, Desktops */
@media only screen and (max-width : 992px){
}
/* Small Devices, Tablets */
@media only screen and (max-width : 768px){
}
/* Extra Small Devices, Phones */
@media only screen and (max-width : 480px){
}
/* Custom, iPhone Retina */
@media only screen and (max-width : 320px){
}

Bootstrap Grid Options On Different Screens


Bootstrap Grid Options

Friday 6 May 2016

What is POCO in Entity Framework


POCO stands for "Plain Old CLR Object" Here CLR means Common Language Rutime that includes dotnet supported languages like C#, VB etc.

A Plain Old CLR Objects (POCO) is a class that doesn't depend on any framework-specific base class. It is like any other normal .Net class; that is why they are called “Plain Old CLR Objects”. These POCO entities support most of the same LINQ queries as Entity Object derived entities.

POCO allows you to write your own entity classes in a persistence ignorant fashion. POCO is also called as Persistence ignorant objects .

Persistence ignorance means that, as much as possible, anything in your code operating at the business logic layer or higher knows nothing about the actual design of the database, what database engine you're running, or how or when objects get retrieved from or persisted to the database. In the case of the EF, persistence ignorance is attained by working on POCO's and using LINQ to perform queries (i.e., not requiring the user to create any SQL queries to retrieve the desired objects).

There is still the need for you to “plug in” persistence and EF  so that your POCO entities can be take from the database and updated back to the database. In order to do this, you will still need to either create an Entity Data Model using the Entity Framework Designer