Hi Im new to ASP and MVC3 and my question is how can i clear the button name parameter in my Post because everytime I refreshes my page after clicking the button with the button parameter , the Value of my last clicked button is still there, is there any way to clear this thing up after Submit or when refreshing the page in Controller or by using Jquery?
Thanks
Heres my Code Snippet:
[HttpPost]
public ActionResult HistoryPage(HistoryModel model, string btnAction)
{
if (Session["HistoryId"] != null)
{
switch (btnAction)
{
case "Delete History":
DeleteHistory(model, ref deleteHistoryError, ref deleteHistorySucesss);
break;
case "AddHistory":
AddHistory(model);
break;
}
}
return View(model);
}
Here is the DeleteHistory
private static void DeleteHistory(HistoryModel model, ref string ErrorMessage, ref string SuccessMessage)
{
foreach (var item in model.HistoryIds)
{
if (item != "")
{
bool result = Int32.TryParse(item, out HistoryIds);
if (result)
{
var History= db.History.Find(HistoryId);
bool HistoryExist = true;
if (History.HistoryId != null)
{
History.LogicalDelete = true;
History.DateModified = DateTime.Now;
db.SaveChanges();
SuccessMessage = "History successfully deleted";
}
else
{
ErrorMessage = "Unable to delete History.";
}
}
}
}
if (!string.IsNullOrWhiteSpace(ErrorMessage))
{
SuccessMessage = String.Empty;
}
}
}
}
my Cshtml Button below my form
<input type="submit" name="btnAction" class="btnMultiDelete button_example button_example_small div-bottom-3 w100Percent txtAlignLeft"
value="Delete History" id="btnDeleteHistory" />