I have one table named announcement when a new data added on this announcement table the count which dispalyed in the _layout.cshtml from a partial view of the same table.. this partial view dispalys the announcements description with count as on the top of the div,. if we add a new announcemetnt on announcement table the count should be automatically incremented without whole page refresh what can i do for this? the code inside the main controller
[HttpPost]
public JsonResult Create(Announcet announcement)
{
try
{
ValidatePageControls(announcement);
//populate error message if model state is not valid
if (!ModelState.IsValid)
{
string errorMsg = GetErrorMessage();
return Json(new { Result = "ERROR", Message = errorMsg });
}
else
{
string entityName = (db as IObjectContextAdapter).ObjectContext.CreateObjectSet<Announcement>().EntitySet.Name;
//used to add sequence.
Int32 nextVal = new PanERP.Common.Common().getNextSequence(entityName);
announcement.AnnouncementId = nextVal;
// Set CREATED_BY & CREATED_DATE ...
db.Announcement.Add(announcement);
//save the entity in DB
db.SaveChanges();
return Json(new { Result = "OK", Record = announcement });
}
}
catch (Exception ex)
{
return Json(new { Result = "ERROR", Message = ex.Message });
}
}
the code inside the partiall view controller
in layout pagere one option is present to increment the count of announcemetn when a new record added in it.. but the count should come after page refresh .. how can i change that