Tuesday, July 5, 2011

ASP.NET Razor - HTML Forms


A form is a section of an HTML document where you put input controls (text boxes, check boxes, radio buttons, and pull-down lists)

Creating an HTML Input Page

Razor Example

@{
if (IsPost) {
    string companyname = Request["companyname"];
    string contactname = Request["contactname"];
    <text>
      You entered: <br />
      Company Name: @companyname <br />
      Contact Name: @contactname <br />
    </text>
    }
}

<html>
<body>
<form method="post" action="">
<fieldset>
<legend>Add Customer</legend>
<div>
<label for="CompanyName">Company Name:</label>
<input type="text" name="CompanyName" value="" />
</div>
<div>
<label for="ContactName">Contact Name:</label>
<input type="text" name="ContactName" value="" />
</div>
<div>
<label>&nbsp;</label>
<input type="submit" value="Submit" class="submit" />
</div>
</fieldset>
</form>
</body>
</html>

No comments:

Post a Comment