I have requested the user to enter in details using textbox and Request.Form, then displayed them at the bottom of the screen as seen here:
Working example:
// C#
string message = "";
string fName;
message = string.Format("Your first name is: " + fName);
// HTML
<div id="questions">
<form method="post">
<label for="fName"></label>
First name: <input type="text" name="fName" id="fName"
value="@(Request.Form["fName"])" /> <br />
<br /><br /><input type="submit" value="Submit" />
<p>@message</p>
This is quite straight forward as there is only 1 box the user can enter this information in, however I do have some dropdown menus in my HTML that I cannot seem to get working in the same way (I have tried many alternative methods and looked up the ASP.NET MVC).
My question: 1. How do I display the secleted option in the dropdown menu that the user enters in the following: and 2. Will the same method work for radio boxes. (The following code is displayed on the page but does not come up when submitted)
// C#
string message = "";
string rStatus;
message = string.Format("Your relationship status is: " + rStatus);
// html
Please enter your gender:
<select id="gender">
<option value="Male">Male</option>
<option value="Female">Female</option>
</select><br />
<br /><br /><input type="submit" value="Submit" />
<p>@message</p>
Aucun commentaire:
Enregistrer un commentaire