I Got A Problem Making A Image Upload To Members To Edit
Có thể bạn quan tâm
Hi I want to make a image upload to my members where they can change their image themselves, but I simply can't find the solution to it. what im i doing wrong.
My update model
using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web; namespace Medlemmer.Models { public class UpdateMember { [Required] public string Name { get; set; } [Required] [EmailAddress] public string Email { get; set; } [Required] public string Password { get; set; } [Required] public string omMig { get; set; } [Required] public HttpPostedFileBase billede { get; set; } } }My update controller
using Medlemmer.Models; using System.Web.Mvc; using Umbraco.Web.Mvc; namespace Medlemmer.Controllers { public class updateMemberController : SurfaceController { [HttpPost] [ActionName("MvcMemberUpdate")] public ActionResult MvcMemberUpdateForm(UpdateMember model) { var memberService = Services.MemberService; var member = memberService.GetByEmail(model.Email); member.SetValue("Navn", model.Name); member.SetValue("avatar", model.billede); member.SetValue("Om mig", model.omMig); memberService.Save(member); TempData["Success"] = true; return RedirectToCurrentUmbracoPage(); } } }member profile page when they are logged in, it is here i want the to edit there image
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Profil> @using ContentModels = Umbraco.Web.PublishedContentModels; @using Medlemmer.Controllers @using Medlemmer.Models @{ Layout = "master.cshtml"; var medlem = Members.GetCurrentMember(); var test = Umbraco.MembershipHelper.GetCurrentMemberProfileModel(); var virker = ApplicationContext.Current.Services.MemberService.GetMembersByMemberType("newsMember"); var bruger = Umbraco.MembershipHelper.GetCurrentMember(); var test1 = ApplicationContext.Current.Services.MemberService.GetAllMembers(); } <div class="container"> <div class="col-md-4"> <img src="@bruger.GetPropertyValue("avatar")" class="img-thumbnail img-responsive" style="width: 100%;" /> @Umbraco.Field("avatarupload") </div> <div class="col-md-8"> <h1 class="page-header">Velkommen @bruger.Name</h1> <p class="text-muted">Email: @test.Email</p> <p class="text-muted">Lidt om mig: @bruger.GetPropertyValue("bio")</p> <p>@bruger.Id</p> </div> </div> <div class="container"> <div class="col-md-8"> @Html.Partial("Rediger profil") </div> </div> } @using (Html.BeginUmbracoForm<RegisterController>("Register")) { <!-- Sikkerhed og skal huskes --> @Html.AntiForgeryToken() @Html.ValidationSummary(true) <div class="container"> <fieldset> <div class="label"> </div> <br /> <div class=""> <h6>Navn: </h6> @Html.EditorFor(Model => Model.Name) @Html.ValidationMessageFor(Model => Model.Name) </div> <br /> <div class=""> <h6>Email: </h6> @Html.EditorFor(model => model.Email) @Html.ValidationMessageFor(model => model.Email) </div> <br /> <div class=""> <h6>Adgangskode:</h6> @Html.EditorFor(model => model.Password) @Html.ValidationMessageFor(model => model.Password) </div> <br /> <div class=""> <h6>Om mig:</h6> @Html.TextAreaFor(model => model.omMig) @Html.ValidationMessageFor(model => model.omMig) </div> <div> @Html.TextBoxFor(m => m.billede, new { type = "file" }) @Html.ValidationMessageFor(model => model.billede) </div> <br /> <button class="btn btn-default">Opret bruger</button> </fieldset> </div> }i have also make the Partial edit profile snippet that umbraco have and i i can add the image upload to that one it would be creat
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using System.Web.Mvc.Html @using ClientDependency.Core.Mvc @using Umbraco.Web @using Umbraco.Web.Controllers @using Medlemmer.Controllers @using Medlemmer.Models @{ var profileModel = Members.GetCurrentMemberProfileModel(); Html.EnableClientValidation(); Html.EnableUnobtrusiveJavaScript(); Html.RequiresJs("/umbraco_client/ui/jquery.js"); Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.min.js"); Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.unobtrusive.min.js"); var success = TempData["ProfileUpdateSuccess"] != null; } @*NOTE: This RenderJsHere code should be put on your main template page where the rest of your script tags are placed*@ @Html.RenderJsHere() @if (Members.IsLoggedIn() && profileModel != null) { if (success) { @* This message will show if RedirectOnSucces is set to false (default) *@ <p>Profilen blev opdateret</p> } using (Html.BeginUmbracoForm<UmbProfileController>("HandleUpdateProfile")) { <fieldset> <legend>Rediger din profil</legend> @Html.ValidationSummary("profileModel", true) @Html.LabelFor(m => profileModel.Name) @Html.TextBoxFor(m => profileModel.Name) @Html.ValidationMessageFor(m => profileModel.Name) <br /> @Html.LabelFor(m => profileModel.Email) @Html.TextBoxFor(m => profileModel.Email) @Html.ValidationMessageFor(m => profileModel.Email) <br /> @Html.TextBoxFor(m => profileModel.billede, new { type = "file" }) @for (var i = 0; i < profileModel.MemberProperties.Count; i++) {@* @Html.LabelFor(m => profileModel.MemberProperties[i].Value, profileModel.MemberProperties[i].Name) By default this will render a textbox but if you want to change the editor template for this property you can easily change it. For example, if you wanted to render a custom editor for this field called "MyEditor" you would create a file at ~/Views/Shared/EditorTemplates/MyEditor.cshtml", then you will change the next line of code to render your specific editor template like: @Html.EditorFor(m => profileModel.MemberProperties[i].Value, "MyEditor") @Html.EditorFor(m => profileModel.MemberProperties[i].Value) @Html.HiddenFor(m => profileModel.MemberProperties[i].Alias) *@ <br /> } <button>Gem</button> </fieldset> } }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
-
Html.editorfor 文件,c# - Stack Overflow-爱代码爱编程 - 爱代码爱编程
-
C# – File Upload ASP.NET MVC - ITecNote
-
Asp.Net MVC File Upload/Update ( Both Image And .Pdf Etc ) With ...