home / software / tips and tricks / How can we use if and foreach loop in HTML page in ASP.net?

How can we use if and foreach loop in HTML page in ASP.net?

Updated:  11/04/2013 13:11 PM
Author:  Shiju Mathews

Status:    Resolved.


In Html code we are able to use the c# code and we are able to use .net language controls like if, switch and loops like for, foreach and while.

The c# language code should be place in <% and %>.

In Visual studio create web form called WebForm1.aspx and modify the code in the aspx page and the code behind as follows.

WebForm1.aspx

Since the aspx page has no idea about the namespace Import jQuery, we need to import the name space using Import

WebForm1.aspx.cs


The web page will display the employee details in a table just like ASP.NET MVC Razor programming.
Tags: How can we use if and foreach loop in HTML page in ASP.net?
Updated on: April 2024