Category: ASP.NET

Asp.net GridView example using C#

Below is a sample code snippet for Asp.net GridView example using C#. The code snippet shows how to populate the GridView with a List of Employees. Asp.net GridView example using C# ASP.NET WebForms <asp:GridView ID=”GridView1″ runat=”server”> </asp:GridView> C# protected void Page_Load(object sender, EventArgs e) { List<Employee> employees = new List<Employee>(); employees.Add(new Employee { Name = “Test1”, Designtaion = “Software Engineer” }); employees.Add(new Employee { Name…

How to Redirect To Action between Areas in ASP.NET MVC?

There are times when you want to redirect to a specific area from different area. In this, one can use the RedirectToAction method to achieve it and pass the parameter area. How to Redirect between Areas in ASP.NET MVC? public ActionResult Index() { return RedirectToAction(“ActionName”, “ControllerName”, new { area = “AreaName” }); } Tutorials you might find interesting:C Program to search a number in an…

What is Fluent Validation in ASP.NET MVC?

Validations can be done in ASP.NET MVC using different techniques. Some of the most commonly used validation techniques include Data Annotations. There is Fluent Validation which can be used for validation as well. What is Fluent Validation in ASP.NET MVC? Fluent Validation is a validation library for .NET. It uses fluent interface and lambda expressions for building validation rules for the business objects in your…

How to find if the request is from Ajax in ASP.NET MVC?

It is easy to find out if the actual request came from Ajax or is it a normal request in ASP.NET MVC. In the controller, one can use the Request.IsAjaxRequest method to find this. How to find if the request is from Ajax in ASP.NET MVC? Below is a sample code snippet demonstrating how to find if the request is from Ajax in ASP.NET MVC?…

Difference between Html.EditorFor and Html.TextboxFor in ASP.NET MVC?

If you are working on Web Application development using ASP.NET MVC, you would come across the Html.EditorFor and Html.TextboxFor in the Razor View. What is the Difference between Html.EditorFor and Html.TextboxFor in ASP.NET MVC? The Html.TextboxFor creates a textbox with the input type of text. It will always render the input textbox. The EditorFor is a kind of smart helper method. This will render the…

How to Retrieve the Current Domain in ASP.NET MVC?

Below is a source code snippet that demonstrates how to obtain the current domain in the controller of the ASP.NET MVC 4 Web Application. How to Retrieve the Current Domain in ASP.NET MVC? public ActionResult Index() { string Domain = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host + (Request.Url.IsDefaultPort ? “” : “:” + Request.Url.Port); return View(Domain); } Tutorials you might find interesting:Azure Q&A – Part 1How-to-[email protected]efonsecabcrSenthil-Kumar-B-Posted-by-Senthil-Kumar-B-August-12-2020-CSharp-3-Min-Read-Microsoft-had-released-the-preview-version-of-.NET-5-some-time-back-which-comes-with-C-9-Preview-too.-While-it-is-sti…C…

How to refresh the HTML Webpage every few seconds automatically using Meta tags?

There may be a scenario where the developer might want to auto refresh the HTML webpage every few seconds automatically. To auto refresh code in html, one can add the metatag with the http-equip=”refresh” and content attribute. The tag http-equiv should be set to “refresh”, the content attribute of the meta tag should be set to the time limit for refresh. How to refresh the…

JavaScript Unit Testing tools

There are plenty of Unit testing tools available which lets the developers to test their JavaScript code easily. In this article , we cover few of the popular JavaScript testing tools. JavaScript Unit Testing tools Karma Karma has the tagline “Spectacular Test Runner for JavaScript”. Karma is a very simple JavaScript Unit Testing tool which is built with node.JS. Karma lets the developers to run…

What is the Difference between Repository and Service Layer in ASP.NET MVC?

Repository pattern, Unit of Work and Service Layer is one of the most commonly used word or technique especially when you are working on the ASP.NET MVC project. What is the Difference between Repository and Service Layer in ASP.NET MVC? These are the common Design pattern terms used in the ASP.NET MVC project. The Repository is a layer that provides additional abstraction on the data…