MVC--View Razor(1)
(1)输出单一变量:
当前时间:@DateTime.Now
(2)输入HTML:@:这是HTML项
(3)C#与HTML混合,输出多行HTML文本时 <text>html文本。。</text>,该标签在前台并没有标识输出
(4)@输出:<div>版权所有jacky@@126.com</div>
<div>版权所有jacky@126.com</div>
(5)C#与HTML混合,多行C#代码:@{}
<div> @{ var a = "中国人民解放军"; var msg = "打印文本框中:" + a; @Html.TextBox("txtPrint", msg, new {style="border:solid 1px red;width:200px;"}); } </div> <p></p> <div> @if (2 > 1) { <text>你好啊 @DateTime.Now</text> @:HTML文本 } else { <div>1=2</div> } </div>
<div> <input id="txtPrint" name="txtPrint" style="border:solid 1px red;width:200px;" type="text" value="打印文本框中:中国人民解放军" /></div> <p></p> <div> 你好啊 2013/9/24 23:21:11 HTML文本 </div>
(6)from表单输出
@Html.ActionLink("QQ门户网", "Member", "login", new { @class="clsssname",age="_link",target="_blank"}) @Html.ActionLink("aa", "login", "Member", new { id = 1 }, new { @class = "-abc", target = "_blank" }) @{Html.BeginForm("login","member",FormMethod.Post,new {enctype="multipart/form-data",id="formlog"});} @{Html.EndForm();} @using (Html.BeginForm("login","member",FormMethod.Get,new {id="formmyLog"})) { @:测试表单 }
<a age="_link" class="clsssname" href="/member/Member?Length=5" target="_blank">QQ门户网</a> <a class="-abc" href="/Member/login/1" target="_blank">aa</a> <form action="/member/login" enctype="multipart/form-data" id="formlog" method="post"></form> <form action="/member/login" id="formmyLog" method="get"> 测试表单</form>