HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Forms are HTML documents to place input controls (text boxes, check boxes, radio buttons, drop-down list) parts.
Suppose there are three images in your image folder you want to display images dynamically based on user selection.
This can be achieved by a simple piece of Razor code.
If there is a picture called "Photo1.jpg" in your site's images folder, you can use the HTML <img> element to display an image, as follows:
The following example demonstrates how to display user selected images from the following list:
The server creates a variable calledimagePath.
HTML page has adrop-down list of named Choice(<select> element). It allows users according to their own will choose a name (such asPhoto 1), when the page is submitted to the Web server, pass a file name (such as Photo1.jpg).
Razor Code byRequest [ "Choice"] reads the value of Choice.If the path through the code to build the image (images / Photo1.jpg) effective, put the image path assigned to the variableimagePath.
HTML page, <img> element is used to display the image. When the page is displayed, src attribute is used to set the value of imagePath variable.
<Img> element is in a block if it is not to prevent the display image name, such as when the page is first loaded displayed.