现在我能够成功上传文件......我现在要做的是在文件成功上传时显示一个警报框,如果没有,则显示错误/异常警报......
这是我的看法:
using (Html.BeginForm("Upload", "Home", FormMethod.Post, new { @id = "File", enctype = "multipart/form-data"}))
{
<div class="control-group">
<input type="file" id="file" name="file" />
<input type="submit" value="Upload" />
</div>
}
这是我的控制器:
[HttpPost]
public ActionResult Upload(HttpPostedFileBase file)
{
try
{
//some code here for the upload....
/*In this part is my problem...Both Lines below is not showing the alert...*/
//return new JavaScriptResult() { Script = "alert('The calendar XML file was uploaded successfully!');" };
//return JavaScript("alert('The calendar XML file was uploaded successfully!');");
}
catch (Exception e)
{
log.Error("HomeController::Upload()", e);
return new JavaScriptResult() { Script = "alert(\"" + e.Message + "\");" };
}
}
我想要的是我的观点仍然存在......页面没有重定向......只是显示该消息的警报框......谢谢!非常感谢任何想法,因为我知道不推荐我的这种方式...... :)