Ext.NET MVC – Form Post to Controller with C# Class Model
Class Model public class Auth { public string username { get; set; } public string password { get; set; } public string role { get; set; } } View /* No JavaScript Code needs to be defined from this. */ /* Native Form Post ( Not AJAX ) would be executed. */ /* If the Form View is from a Tab Panel, it would be embedded from an iFrame based on Ext.Net Framework. When Form Post Redirect from an iFrame is executed, the Other Tab under the Tab Panel would remain unchange. This Design seems fancy for some Information System which needs to be opened many Tab to be used at the same time. If the System Team or Organization do not want to rely on Ext.Net Framework due to Pricing, Compatibility on Browser Upgrade or Something Else, it is possible to have a Self-Development on this Feature from the Framework. */ @( X.Window() .ID("Form") .Closable(false) .Resizable(false) .Height(400) .Title("Login") .Width(350) .Layout(LayoutType.Form) .AutoEl(el => { el.Tag = HtmlTextWriterTag.Form; el.CustomConfig.Add(new ConfigItem() { Name = "method", Value = "POST", Mode = ParameterMode.Value }); }) .Items( X.TextField() .ID("txtUsername") .Name("username") .FieldLabel("Username"), X.TextField() .ID("txtPassword") .Name("password") .InputType(Ext.Net.InputType.Password) .FieldLabel("Password"), X.TextField() .ID("txtRole") .Name("role") .FieldLabel("Role") ) .Buttons( X.Button() .Text("Save") .Icon(Icon.Accept) .FormBind(true) .DirectEvents(de => { de.Click.Url = Url.Action("AuthForm"); de.Click.Method = HttpMethod.POST; de.Click.EventMask.ShowMask = true; de.Click.EventMask.Msg = "Verifying…"; de.Click.EventMask.MinDelay = 4000; }) ) ) Controller [HttpPost] public ActionResult AuthForm(Auth auth) { DirectResult r = new DirectResult(); if( … … ) return RedirectToAction("AccessDenied"); else return RedirectToAction("Index"); } |