如何实现MVC ActionResult 返回类型为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 style="padding-left:1em">@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>
}
Controller
if (string.IsNullOrEmpty(model.ReceiptNo) || string.IsNullOrEmpty(model.SavePath) || string.IsNullOrEmpty(model.PicPath))
{
return base.JavaScript("alert('信息有误,不能上传')");
}
效果

如何实现MVC ActionResult 返回类型为JavaScriptResult的更多相关文章
- MVC Action 返回类型[转]
一. ASP.NET MVC 1.0 Result 几何? Action的返回值类型到底有几个?咱们来数数看. ASP.NET MVC 1.0 目前一共提供了以下十几种Action返回 ...
- MVC Action 返回类型
https://www.cnblogs.com/xielong/p/5940535.html https://blog.csdn.net/WuLex/article/details/79008515 ...
- ActionResult 返回类型
类名 抽象类 父类 功能 ContentResult 根据内容的类型和编码,数据内容. EmptyResult 空方法. FileResult abstract 写入文件内容,具体 ...
- mvc actionresult返回各种文件
public ActionResult ReviewFile(string folderName, string fileBasename, string extendName) { //以后根据后缀 ...
- 了解ASP.NET MVC几种ActionResult的本质:JavaScriptResult & JsonResult
在之前的两篇文章(<EmptyResult & ContentResult>和<FileResult>)我们剖析了EmptyResult.ContentResult和F ...
- Asp.Net Mvc 返回类型总结
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- ASP.NET MVC 中使用JavaScriptResult asp.net mvc 返回 JavaScript asp.mvc 后台返回js
return this.Content("<script>alert('暂无!');window.location.href='/Wap/Index';</script&g ...
- ASP.NET Core WebAPI控制器返回类型的最佳选项
前言 从.NET Core 2.1版开始,到目前为止,控制器操作可以返回三种类型的WebApi响应.这三种类型都有自己的优点和缺点,但都缺乏满足REST和高可测性的选项. ASP.NET Core中可 ...
- asp.net core系列 38 WebAPI 返回类型与响应格式--必备
一.返回类型 ASP.NET Core 提供以下 Web API Action方法返回类型选项,以及说明每种返回类型的最佳适用情况: (1) 固定类型 (2) IActionResult (3) Ac ...
随机推荐
- 基于springboot实现Java阿里短信发送
1.接口TestController import java.util.Random; import com.aliyuncs.DefaultAcsClient; import com.aliyunc ...
- error LNK2019: 无法解析的外部符号……
在VS中开发程序的时候遇到一个问题,应该算是比较常见,所以记录下. 在编译程序的时候遇到一个错误,大致提示如下: "error LNK2019: 无法解析的外部符号--" 遇到这个 ...
- mcu运行时间估算
昨个伙计问我他那个板子的程序运行时间估算问题… 现在说一下估算的思路.首先确定有几个点,板子的主频.时钟周期,机器周期. 首先由主频f得到一个时钟周期为1/f. 再者时钟周期与机器周期有一个比例关系, ...
- 剑指offer - 顺时针打印矩阵 - JavaScript
题目描述 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下 4 X 4 矩阵: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 则依次打印 ...
- python-arp 被动信息收集
python-arp 被动信息收集 概述 横向移动的时候由于局域网中可能存在未分配的IP,如果请求这些未分配的IP可能导致被发现(旁路检测设备),先可以做一下arp被动信息收集.当然对蜜罐类设备没用. ...
- js原型链理解(4)-经典继承
经典继承就是组合继承,就是组合构造函数和原型链的优点混合继承. 1.避免引用类型的属性初始化 2.避免相同方法的多次初始化 function Super(name){ this.ages = [100 ...
- POJ 1320:Street Numbers
Street Numbers Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 2753 Accepted: 1530 De ...
- vs2012(或2013)与虚拟机连调试
一.安装Windows Driver Kit 8 1首先在计算机上安装VS2012 (12很容易安装,安装步骤略),然后到官网上下载Windows Driver Kit 8 下载地址: http:// ...
- 8 —— node —— 响应一切 html 需要的静态资源
fs.readFile('.'+urls, function (err, data) { res.end(data) });
- 20 - CommonJS - 规范的具体内容