Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

ASP.NET Web Pages HTML Forms

ASP.NET Web Pages - HTML Forms


A form is the part of an HTML document that holds input controls (text boxes, check boxes, radio buttons, drop-down lists).


Create an HTML Input Page

Razor Example

@{
if (IsPost) {
string companyname = Request["companyname"];
string contactname = Request["contactname"];

You entered:

Company Name:

@companyname


Contact Name:

@contactname

}
else
{

Company Name:


Contact Name:



}

}

Run Example »


Razor Example - Display Image

Suppose you have 3 images in your image folder and you want to dynamically display an image based on the user's selection.

This can be achieved with a simple piece of Razor code.

If there is an image named "Photo1.jpg" in your website's image folder, you can use the HTML element to display the image, as shown below:

Sample

The example below demonstrates how to display the image selected by the user from the list below:

Razor Example

@{
var imagePath="";
if (Request["Choice"] != null)
{imagePath="images/" + Request["Choice"];}
}

Display Images

I want to see:

@if (imagePath != "")
{

Sample

}

Run Example »

Example Explanation

The server creates a variable called imagePath .

The HTML page has a Choice 'sdrop-down list(