问题
Does anyone tried Kendo UI notifications from MVC server side, like MvcFlashMessages?
I want to show "succeed or error" notification after form submit(In my scenario, after form submit Controller action redirects to view with items list and i want to show succeed notification).
Or maybe more different scenario like after grid item create/delete/edit notification show but notification must rise from server side if some errors occurs not only from JS.
Thanks for attention.
回答1:
First of all you can check this website. http://demos.telerik.com/kendo-ui/notification/templates
I gave you an example about it.
$(document).ready(function () {
var addUserUrl = "<%=Url.Action("AddUser", "ControlAccount")%>";
$("#addUser").click(function addUserFunc() {
var userName= 'exampleUser';
var password = 'examplePassword';
$.post(addUserUrl, { userName: userName, password: password}, function (data, result) {
var d = new Date();
staticNotification.show(kendo.toString(d, 'HH:MM:ss.') + kendo.toString(d.getMilliseconds(), "000"), text);
var container = $(staticNotification.options.appendTo);
container.scrollTop(container[0].scrollHeight);
});
});
In the server side ;
[HttpPost]
public ActionResult AddUser(string kullaniciAdi, string password)
{
var result = "";
//// Do it your jobs
return Json(result, JsonRequestBehavior.AllowGet);
}
来源:https://stackoverflow.com/questions/27899393/kendo-ui-notifications-and-mvc