sample.razor.txt 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. @{
  2. var total = 0;
  3. var totalMessage = "";
  4. @* a multiline
  5. razor comment embedded in csharp *@
  6. if (IsPost) {
  7. // Retrieve the numbers that the user entered.
  8. var num1 = Request["text1"];
  9. var num2 = Request["text2"];
  10. // Convert the entered strings into integers numbers and add.
  11. total = num1.AsInt() + num2.AsInt();
  12. <italic><bold>totalMessage = "Total = " + total;</bold></italic>
  13. }
  14. }
  15. <!DOCTYPE html>
  16. <html lang="en">
  17. <head>
  18. <title>Add Numbers</title>
  19. <meta charset="utf-8" />
  20. </head>
  21. <body>
  22. <p>Enter two whole numbers and then click <strong>Add</strong>.</p>
  23. <form action="" method="post">
  24. <p><label for="text1">First Number:</label>
  25. <input type="text" name="text1" />
  26. </p>
  27. <p><label for="text2">Second Number:</label>
  28. <input type="text" name="text2" />
  29. </p>
  30. <p><input type="submit" value="Add" /></p>
  31. </form>
  32. @* now we call the totalMessage method
  33. (a multi line razor comment outside code) *@
  34. <p>@totalMessage</p>
  35. <p>@(totalMessage+"!")</p>
  36. An email address (with escaped at character): name@@domain.com
  37. </body>
  38. </html>