如何实现MVCActionResult返回类型为JavaScriptResult
必需的js引⽤⽂件
<script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
@Scripts.Render("~/bundles/jquery")
View页⾯
@using (Ajax.BeginForm("EditGPY", "GPY", new AjaxOptions(), new { @id = "frmgpy", @class = "form-horizontal" }))
{
@Html.HiddenFor(m => m.PicPath)
<table>
<tr><td>保存路径</td><td >@Html.TextBoxFor(m => m.SavePath, new { @class = "form-control", @id = "FilePath", @readonly = "readonly" })</td></tr> </table>
<div class="form-group">
<div class="col-md-10">
@Html.HiddenFor(m => m.ReceiptNo, new { @id = "txtReceiptNo" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input data-ajax="true" type="submit" class="btn btn-primary" value="上传⽂件"/>
</div>
</div>
}
mvc三层架构如何实现
Controller
if (string.IsNullOrEmpty(model.ReceiptNo) || string.IsNullOrEmpty(model.SavePath) || string.IsNullOrEmpty(model.PicPath))
{
return base.JavaScript("alert('信息有误,不能上传')");
}
效果

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。