在我的控制,我总是最后的东西,如:如何将函数传递给方法?
[HttpPost]
public ActionResult General(GeneralSettingsInfo model)
{
try
{
if (ModelState.IsValid)
{
// Upload database
db.UpdateSettingsGeneral(model, currentUser.UserId);
this.GlobalErrorMessage.Type = ErrorMessageToViewType.success;
}
else
{
this.GlobalErrorMessage.Type = ErrorMessageToViewType.alert;
this.GlobalErrorMessage.Message = "Invalid data, please try again.";
}
}
catch (Exception ex)
{
if (ex.InnerException != null)
while (ex.InnerException != null)
ex = ex.InnerException;
this.GlobalErrorMessage.Type = ErrorMessageToViewType.error;
this.GlobalErrorMessage.Message = this.ParseExceptionMessage(ex.Message);
}
this.GlobalErrorMessage.ShowInView = true;
TempData["Post-data"] = this.GlobalErrorMessage;
return RedirectToAction("General");
}
什么,我想这样做会是这样的:
[HttpPost]
public ActionResult General(GeneralSettingsInfo model)
{
saveModelIntoDatabase(
ModelState,
db.UpdateSettingsGeneral(model, currentUser.UserId)
);
return RedirectToAction("General");
}
我将如何传递一个函数作为参数?就像我们做的JavaScript:
saveModelIntoDatabase(ModelState, function() {
db.UpdateSettingsGeneral(model, currentUser.UserId)
});
'行动 myFunction' –
''delegate'行动<>'' Func <>' –