Asp.net mvc 3 在Controller.cs文件中找到@HTML.EditorFor(model=>;model.Username)Controller
我使用了HTMLEditor代码,如下所示 我只想从单击中清除一个HTMLEditor。如何在controller.cs文件中找到特定的HTML编辑器控件Asp.net mvc 3 在Controller.cs文件中找到@HTML.EditorFor(model=>;model.Username)Controller,asp.net-mvc-3,razor,Asp.net Mvc 3,Razor,我使用了HTMLEditor代码,如下所示 我只想从单击中清除一个HTMLEditor。如何在controller.cs文件中找到特定的HTML编辑器控件 @model Blog.Models.User @{ ViewBag.Title = "Register New User"; } @using Microsoft.Web.Mvc; @using MVC3MultiSubmitButtonExtension; <h2> Register New User</
@model Blog.Models.User
@{
ViewBag.Title = "Register New User";
}
@using Microsoft.Web.Mvc;
@using MVC3MultiSubmitButtonExtension;
<h2>
Register New User</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm("Create", "Home", FormMethod.Post))
{
@Html.ValidationSummary(true)
<fieldset>
<legend>Fill User Details</legend>
<div class="editor-label">
@Html.LabelFor(model => model.FirstName)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.FirstName)
@Html.ValidationMessageFor(model => model.FirstName)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.LastName)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.LastName)
@Html.ValidationMessageFor(model => model.LastName)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Username)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Username)
@Html.ValidationMessageFor(model => model.Username)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Password)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Password)
@Html.ValidationMessageFor(model => model.Password)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.EmailAddress)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.EmailAddress)
@Html.ValidationMessageFor(model => model.EmailAddress)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.MobileNumber)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.MobileNumber)
@Html.ValidationMessageFor(model => model.MobileNumber)
</div>
<p>
@* <input type="submit" value="Create" />*@ @*@Html.MultiSubmitButton(Url.Action("Create"), "btnCreate", "Create")*@
@* @Html.MultiSubmitButton(Url.Action("Cancel"), "btnCancel", "Cancel", new { @class = "cancel" })*@
<input type="submit" id="btnSubmit" name="btnSubmit" value="Submit" />
<input type="submit" id="btnReset" name="btnReset" value="Reset"
class="cancel" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Click here to go Login Page", "Index")
</div>
@model Blog.Models.User
@{
ViewBag.Title=“注册新用户”;
}
@使用Microsoft.Web.Mvc;
@使用MVC3MultiSubmitButtonExtension;
注册新用户
@使用(Html.BeginForm(“Create”、“Home”、FormMethod.Post))
{
@Html.ValidationSummary(true)
填写用户详细信息
@LabelFor(model=>model.FirstName)
@EditorFor(model=>model.FirstName)
@Html.ValidationMessageFor(model=>model.FirstName)
@LabelFor(model=>model.LastName)
@EditorFor(model=>model.LastName)
@Html.ValidationMessageFor(model=>model.LastName)
@LabelFor(model=>model.Username)
@EditorFor(model=>model.Username)
@Html.ValidationMessageFor(model=>model.Username)
@LabelFor(model=>model.Password)
@EditorFor(model=>model.Password)
@Html.ValidationMessageFor(model=>model.Password)
@LabelFor(model=>model.EmailAddress)
@EditorFor(model=>model.EmailAddress)
@Html.ValidationMessageFor(model=>model.EmailAddress)
@LabelFor(model=>model.MobileNumber)
@EditorFor(model=>model.MobileNumber)
@Html.ValidationMessageFor(model=>model.MobileNumber)
@**@@*@Html.MultiSubmitButton(Url.Action(“创建”),“btnCreate”,“创建”)*@
@*@Html.MultiSubmitButton(Url.Action(“取消”),“btnCancel”,“取消”,新建{@class=“取消”})*@
}
@ActionLink(“单击此处进入登录页面”,“索引”)
我只想为EmailAddress HTML编辑器设置string.empty。如果要在单击按钮时重置完整表单,可以将按钮类型设置为
type=“reset”
<input type="reset" id="btnReset" name="btnReset" value="Reset" />
<input id="clearEmailAddress" type="button" value="Clear Email Address" />
<script type="text/javascript>
$("#clearEmailAddress").click(function(){
$(this).closest('form').find("input[name='EmailAddress']").val("");
});
</script>