Html.editorfor 文件,c# - Stack Overflow-爱代码爱编程 - 爱代码爱编程
Có thể bạn quan tâm
代码编织梦想
html.editorfor 文件,c# - @Html.EditorFor (Image) - Stack Overflow-爱代码爱编程 Posted on2021-06-18 分类: html.editorfI am trying to allow a user to upload an image to our website and I'm not quite sure about how to use this. I have tried to use multiple types to define the image, including System.Drawing.Image and HttpPostedFileWrapper but the @Html.EditorFor always (understandably) brings up its attributes as fields to edit.
In my view I did have, instead of @Html.EditorFor I did have but it didn't get taken through to my view as part of the Model? I am quite new to MVC so I am hoping it is something trivial.
Here is my View:
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
New Image
@Html.LabelFor(model => model.Description)
@Html.EditorFor(model => model.Description)
@Html.ValidationMessageFor(model => model.Description)
@Html.LabelFor(model => model.Image)
}
My Controller:
[HttpPost]
public ActionResult CreateImage(string brand, string collection, ImageEditViewModel imageEditViewModel)
{
string fileName = Guid.NewGuid().ToString();
string serverPath = Server.MapPath("~");
string imagesPath = serverPath + String.Format("Content\\{0}\\Images\\", Helper.Helper.ResolveBrand());
string newLocation = Helper.Helper.SaveImage(fileName, imagesPath, imageEditViewModel.Image.InputStream)
Image image = new Image
{
Collection = ds.Single(c => c.Season == collection
&& c.Brand.Name == brand),
Description = imageEditViewModel.Description,
Location = "newLocation",
Order = Helper.Helper.GetImageOrder(brand, collection)
};
ds.InsertOnSubmit(image);
ds.SubmitChanges();
return RedirectToAction("Brand");
}
And finally the ViewModel:
public class ImageEditViewModel
{
public int CollectionId { get; set; }
public string Description { get; set; }
public HttpPostedFileWrapper Image { get; set; }
public int Order { get; set; }
}
Post navigation
html.editorfor 文件,@Html.EditorFor() 用法-爱代码爱编程 html.editorfor css,css - HTML.EditorFor adding class not working - Stack Overflow-爱代码爱编程ecw2c理解元数据:使用BigQuery k-means将4,000个堆栈溢出标签聚类-爱代码爱编程
2019-07-24 分类: uncategorized您如何将超过4,000个活动的Stack Overflow标签分组为有意义的组? 对于无监督学习和k均值聚类来说,这是一项完美的任务-现在您可以在BigQuery中完成所有这些工作。 让我们找出方法。 Visualizing a universe of clustered tags. Felipe Hoffa is a Develop
Continue Reading非常有用的知识大全-爱代码爱编程
2021-06-08 分类: 生活随想文章目录 编程语言前端开发后端开发计算机科学大数据理论各类平台书籍编辑器游戏开发开发环境娱乐数据库多媒体学习资源安全内容管理系统硬件商业量化交易与金融工作网络区块链高等教育大事件测试MiscellaneousRelated 编程语言 JavaScript PromisesStandard Style - 编程规范指南.Must Watc
Continue Reading前端技术
browser Chrome Edge wechat Vue.js CSS React Flutter Angular Next.js Ionic Nuxt.js编程语言
C Java python PHP JavaScript Node.js HTML .NET Rust C# Kotlin Typescript Lua系统软件
Server DNS Nginx Apache mysql Postgresql Docker Kubernetes MongoDB Redis Elasticsearch linux ubuntu debian centos FreebsdMeta
- github 中文
- 爱代码爱编程
- 飞猫文件传输
RECENTLY POSTS
- html.editorfor 样式,EditorStyles 编辑样式-爱代码爱编程
- html.editorfor怎么加样式,HTML.EditorFor添加类不起作用-爱代码爱编程
- html.editorfor默认值,Html.EditorFor Set Default Value-爱代码爱编程
- html.editorfor 禁用,ZKEACMS中的Html.EditorForModel()-爱代码爱编程
- html.editorfor 禁用,html – 如何使用EditorFor禁用输入字段的自动完成功能?-爱代码爱编程
- html.editorfor css,css - Html.EditorFor How to set bootstrap class and HTML attributes? - Stack Over...-爱代码爱编程
- html.editorfor使用css,Add css class to Html.EditorFor in MVC 2-爱代码爱编程
Từ khóa » Html.editorfor Image Upload
-
C# - @Html.EditorFor (Image) - Stack Overflow
-
How To Create EditorFor FileUpload In Mvc 4 Razor?
-
How To Upload Image In Edit And Create View? (ASP.Net MVC) - MSDN
-
ASP.NET MVC Form With File Upload - C# Corner
-
EditorFor Image Browser Is Encoding Image Url - Telerik
-
C# - Uploading Image In ASP.NET MVC
-
How To Upload Image In Mvc Using Model - Tech Altum Tutorial
-
Can Editorfor Be Used To Create Input Type File
-
Upload Selected File With Form Data In ASP.Net MVC - ASPsnippets
-
Image Upload On ASP.NET MVC With TinyMCE - İsmail Erdem Sırma
-
Image Upload Processing - ASP.NET MVC HTML Content Editor
-
C# – File Upload ASP.NET MVC - ITecNote
-
Asp.Net MVC File Upload/Update ( Both Image And .Pdf Etc ) With ...
-
I Got A Problem Making A Image Upload To Members To Edit