A form is a section of an HTML document where you put input controls (text boxes, check boxes, radio buttons, and pull-down lists)
Suppose you have 3 images in your image folder, and you want to display images dynamically by the users choice.
This is easily done by a little Razor code.
If you have an image called "Photo1.jpg" in your images folder on your web site, you can display the image using an HTML <img> element like this:
The example below shows how to display a selected picture which the user selects from a drop-down list:
The server creates a variable called imagePath.
The HTML page has a drop-down list (a <select> element) named Choice. It lets the user select a friendly name (like Photo 1), and passes a file name (like Photo1.jpg) when the page is submitted to the web server.
The Razor code reads the value of Choice by Request["Choice"]. If it has a value the code constructs a path to the image (images/Photo1.jpg, and stores it in the variable imagePath.
In the HTML page there is an <img> element to display the image. The src attribute is set to the value of the imagePath variable when the page displays.
The <img> element is in an if block to prevent trying to display an image with no name (like the first time the page is displayed.
The perfect solution for professionals who need to balance work, family, and career building.
More than 10 000 certificates already issued!
The HTML Certificate documents your knowledge of HTML.
The HTML5 Certificate documents your knowledge of advanced HTML5.
The CSS Certificate documents your knowledge of advanced CSS.
The jQuery Certificate documents your knowledge of jQuery.
The XML Certificate documents your knowledge of XML, XML DOM and XSLT.
The ASP Certificate documents your knowledge of ASP, SQL, and ADO.
The PHP Certificate documents your knowledge of PHP and SQL (MySQL).
Your message has been sent to W3Schools.