asp.mvc怎么写html5

html-css08

asp.mvc怎么写html5,第1张

Html 5 的有一些File API,对Form表单增强的特性,让我们轻松支持多文件上传,看下面的Html片断代码:

<form action="/Home/Upload" enctype="multipart/form-data" id="form2" method="post">

<input type="file" name="fileToUpload" id="fileToUpload2" multiple="multiple" />

<input type="submit" value="submit" />

</form>

那在Asp.net MVC web application中,我们可以这么实现:

@using (Html.BeginForm("Upload", "Home", FormMethod.Post, new { enctype = "multipart/form-data", id = "form2" }))

{

<label for="file">Upload Image:</label>

<input type="file" name="fileToUpload" id="fileToUpload2" multiple="multiple" />

<input type="submit" value="Upload Image by submit" />

}

假设这是一个HomeController下View, 即将提交到Upload的Action,看下面服务端的代码:

[HttpPost]

public ActionResult Upload(HttpPostedFileBase[] fileToUpload)

{

foreach (HttpPostedFileBase file in fileToUpload)

{

string path = System.IO.Path.Combine(Server.MapPath("~/App_Data"), System.IO.Path.GetFileName(file.FileName))

file.SaveAs(path)

}

ViewBag.Message = "File(s) uploaded successfully"

return RedirectToAction("Index")

}

你这个看不出来啥,,唯一能让你报错的就是<% call show() %>

那得看看你SHOW方法里写的是啥东西。逐步的找问题。

另外我想说ASP这么古老级的玩意还有人在用?

asp.net是一个东西 早期的asp早就淘汰了 现在说的aps都是asp.net

aps和php是一个等级的东西 php比较简单 asp要先学c#比较难 php也比asp更容易找到工作 但是平均工资要低于asp

初学者先从学html5之前先从html学起把 还是js 没有js基础html5根本学不来 然后在学php或者asp