详解ASP.NET Razor 语法(2)

@{ var totalMessage = ""; if(IsPost) { var num1 = Request["text1"]; var num2 = Request["text2"]; var total = num1.AsInt() + num2.AsInt(); totalMessage = "Total = " + total; } } <html> <body> <form action="" method="post"> <p><label for="text1">First Number:</label><br> <input type="text" /></p> <p><label for="text2">Second Number:</label><br> <input type="text" /></p> <p><input type="submit" value=" Add " /></p> </form> <p>@totalMessage</p> </body> </html>

输出

详解ASP.NET Razor 语法

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/6e6b9776fca8e7a907b77abca682f320.html