Net. Please help me. I have a void deletephoto method in my controller productmasters. The following is that method :
[HttpPost]
[ValidateAntiForgeryToken]
public void DeletePhoto(ProductMaster productMaster,string id,string cid)
{
ProductMaster productMaster1 = (from p in db.ProductMasters
where p.ProductID == id && p.CompanyID == cid
select p).FirstOrDefault();
string fullPath = Server.MapPath(productMaster1.ImagePathAndName);
if (System.IO.File.Exists(fullPath))
{
System.IO.File.Delete(fullPath);
}
productMaster1.ImagePathAndName = null;
productMaster1.Image = null;
db.Entry(productMaster1).State = EntityState.Modified;
db.SaveChanges();
}
In my edit view I have a remove photo link:
<div>
@Html.ActionLink("Remove Photo", "DeletePhoto", new { id = Model.ProductID, cid = Model.CompanyID })
</div>
The problem is: How can I execute the void method in this controller without refreshing the edit view.
Thanks in advance.