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 …

How to Set/Get the value of Label Control in ASP.Net using jQuery

We can divide this question into 2 parts Set the value of Label control using jQuery Get the value of Label Control using jQuery Before answering each of these questions, we can revisit some basics for better understanding asp:Label is a server side ASP.Net control and resides at server side. When you request a page which contains Label control, ASP.Net …

Sending DateTime to jQuery Ajax in JSON format in ASP.Net

You want to send DateTime from code behind to client using jQuery AJAX. There is a little problem here. DateTime is a .Net structure whereas jQuery/javascript does not have any idea about it. DateTime is .Net structure which has the value of number of ticks(100 nanoseconds) since 1st Jan 0001 mightnight AD. As this is a .Net structure, only ASP.Net …

Get selected text and value from Drop Down List in ASP.Net using jQuery

You want to get the selected text and value from DropDownList control of ASP.Net using jQuery. Sidenote: Complete code is available at the bottom of the article. But I recommend you to read the article completely for better understanding. Every item in the drop down list has 2 parameters – Text and Value. In the below drop down list, 1st …