Hi,
I have a question regarding posting data to MVC controller (action).
If we use Razor, what would be the best practice?
Could you give me some example for let's say login page? Something like this?
html: what is the best practice using Kendo UI, HTML5, MVC?
C# code: how this part should look like?
I have a question regarding posting data to MVC controller (action).
If we use Razor, what would be the best practice?
Could you give me some example for let's say login page? Something like this?
html: what is the best practice using Kendo UI, HTML5, MVC?
<div id="view">
<input type="text" data-bind="value: UserName" required /><input type="text" data-bind="value: Password" required /><button data-bind="click: LogOn">Log On</button></div><script>$(document).ready(function () { var validatable = $("#view").kendoValidator().data("kendoValidator");var viewModel = { LogOn: function () {var userName = this.get("UserName"); var password = this.get("Password"); if (validatable.validate()) { //What should be done here in order to send username and password? }}
};
kendo.bind($("#view"), viewModel);}); </script>
C# code: how this part should look like?
public class AccountController : Controller {
[HttpPost] public ActionResult LogOn(LogOnModel model, string returnUrl) {if (ModelState.IsValid) { if (Membership.ValidateUser(model.UserName, model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return Redirect(returnUrl); } else { return RedirectToAction("Index", "Home"); } } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } }
return View(model);
} }