begınnıng index form
<tbody>
@foreach (var dolas in Model)
{
<tr>
<td>@dolas.KATEGORIID </td>
<td>@dolas.KATEGORIAD </td>
<td>@dolas.RESIMYOLU </td>
<td>
<img src="@Url.Content(@dolas.RESIMYOLU)" width="250" height="250" />
</td>
<td><a href="/kategoriler/resekle/@dolas.KATEGORIID" class="btn btn-success"> ımage add</a> </td>
</tr>
}
</tbody>
layout1 (resekle) other form
@model MYUCEDAGTICARI.Models.baglantientities.KATEGORILER
<h2>URUN EKLE</h2>
@*<input type="text" value="@Model.KATEGORIID" />*@
<form action="/kategoriler/katresislem" method="post" enctype="multipart/form-data">
<input type="text" id="@Model.KATEGORIID" value="@Model.KATEGORIID" />
<br />
RESIM YUKLE: <input type="file" name="filename1" id="filename1" /> <br />
<div class="form-group">
<br />
<br />
<a href="/kategoriler/index">IPTAL </a>
<input type="submit" value="KAYDET" />
</div>
</form>
layout 2 (resekle) other form
@*orjınalınde asagıdakı satır yok ama burda valıdate sartları var *@
@model MYUCEDAGTICARI.Models.baglantientities.KATEGORILER
@{
ViewBag.Title = "guncelle";
Layout = "~/Views/shared/Anamasterform.cshtml";
}
@*<input type="text" id="@Model.KATEGORIID" value="@Model.KATEGORIID" />*@
@using (Html.BeginForm("katresislem", "kategoriler", FormMethod.Post,new { enctype="multipart/form-data"}))
{
<div class="form-group">
@Html.LabelFor(m => m.KATEGORIID)
@Html.TextBoxFor(m => m.KATEGORIID, new { @class = "form-control" })
@Html.LabelFor(m => m.KATEGORIAD)
@Html.TextBoxFor(m => m.KATEGORIAD, new { @class = "form-control" })
<input type="file" name="filename1" id="filename1" />
</div>
<button class="btn btn-danger">GUNCELLE</button>
}
controller side
public ActionResult resekle(int id)
{
var deg1 = db.KATEGORILER.Find(id);
return View("resekle", deg1);
}
[HttpPost]
public ActionResult katresislem(KATEGORILER p, HttpPostedFileBase filename1)
{
var deg = db.KATEGORILER.Find(p.KATEGORIID);
string uzantisizdosism = Path.GetFileNameWithoutExtension(p.filename1.FileName);
string uzanti = Path.GetExtension(p.filename1.FileName);
string dosyaismie = uzantisizdosism + DateTime.Now.ToString("yymmssfff") + uzanti;
string dosyaismik = uzantisizdosism + DateTime.Now.ToString("yymmssfff") + uzanti;
deg.RESIMYOLU = "~/resimler/" + dosyaismie;
dosyaismie = Path.Combine(Server.MapPath("~/resimler/"), dosyaismie);
p.filename1.SaveAs(dosyaismie);
deg.KATEGORIAD= "onurbaba";
//u.id = 1;
//deg.KATEGORIID = p.KATEGORIID;
//db.KATEGORILER.Add(deg);
db.Entry(deg).State = System.Data.Entity.EntityState.Modified;
db.SaveChanges();
ModelState.Clear();
return RedirectToAction("index");
kategorı cs entıty
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MYUCEDAGTICARI.Models.baglantientities
{
using System;
using System.Collections.Generic;
using System.Web;
public partial class KATEGORILER
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public KATEGORILER()
{
this.URUN = new HashSet<URUN>();
}
public short KATEGORIID { get; set; }
public string KATEGORIAD { get; set; }
public string RESIMYOLU { get; set; }
public HttpPostedFileBase filename1 { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<URUN> URUN { get; set; }
}
}
According to this code, the layout 2 form works without any problems, but the layout 1 form cannot receive the parameter on the control side. Layout 1 is a classic page, how should the common control of this page be, great teacher?