$ symbol in jQuery (and in javascript)

Before discussing about the functionality of ‘$’ in jQuery, let us take a look at what it( $ sign) means with respect to JavaScript, as a language. With respect to javaScript, $ symbol is just a valid identifier. Consider the following code snippet $ = 5; console.log($); The above code snippet would just print number 5 in the console. So, …

var in C#

Using var keyword, you can declare and initialize variable of any type.  By the initialization value, the type of variable (created using ‘var’ keyword) would be decided. Let us see an example var varString = “Hello World”; var varInt = 32; Console.WriteLine(varString.GetType()); // Will print System.String Console.WriteLine(varInt.GetType()); // Will print System.Int32 In the above code snippet, we are declaring couple of variables varString, varInt and assigning string value (“Hello World”) , integer value(32) respectively. When you …

Difference between fields and properties in C#

If you are a beginner, you might get confused between a field and a property. You can store value using either a field or a property and retrieve the value back. You can even protect both fields and properties using access modifiers such as private or protected. So you might wonder, why we need to have property when you can …

Difference between string in String in C#

If you are new to C#, you might wonder what’s the difference between String(with capital S) and string (with small s) in C#. string(with small s) is a keyword in C# which represents the System.String type in Common Type System whereas the String (with capital S) is the shorthand notation for System.String.  Consider the following code snippet where we declare …

Why we use HTML helpers in ASP.Net MVC instead of normal ASP.Net Controls?

If you are from ASP.Net Web Forms background, you might’ve wondered why we are using HTML helpers instead of ASP.Net controls in ASP.Net MVC? It is easy to use ASP.Net controls such as asp:TextBox – isn’t it? Because ASP.Net WebForms controls remember what you typed in the form and you can easily get the property by using .Text in C# …

Pass data from View to Controller in ASP.Net MVC

There are many ways to pass data from Controller to View – ViewBag,ViewData, TempData,though a Model. But you wonder how you can pass data from View to Controller Looking for quick answer? If you came from Google and are looking for quick answer, the answer is this: you’ll have to submit the form (in the View) either through GET or …

Partial View in ASP.Net MVC

Partial Views are just views which we can reuse across your ASP.Net MVC application. You can think Partial View as a reusable control. You don’t need to write code for them every time – You can drop Partial View like a block wherever you want to and content of the partial view would be displayed. We will discuss about following …

Ignore class property to table column in Entity Framework Code First

There are times when you don’t want to map a property in a class to the table column in Entity Framework Code First. Let us consider the following Customer Model class In this Customer model class, we have a property by Name “FullName” . We would use this property to display the complete name of the customer in our application. …

Getting textbox input value in ASP.Net MVC

You want to get the input using textbox in your ASP.Net MVC application. And you want to get that value in your controller’s action method for saving it to database or for further processing. Before arriving at the solution, let us revisit a simple fact All browsers can understand only HTML,CSS and Javascript. The above statement is true irrespective of …

Calling Stored Procedure from Entity Framework 6 Code First

You don’t want Entity Framework to execute plain SQL queries when inserting/updating data into database when using Code First. Instead, you would like to call Stored Procedures. Let us see first what the existing behavior is when saving information to the database and how we can make Entity Framework to use Stored Procedures instead of SQL queries. Below is the …