我有一个表单,用户必须填充一些值。单击按钮提交后,我需要调用javascript函数并检查返回值,如果返回值为真,我需要发回表单。如何使用 devexpress 按钮实现这一点?
当我把
saveSett.UseSubmitBehavior = true;
在按钮设置中,并将断点放在控制器操作的第一行,我看到它没有去那里。
这是我的看法:
@model Models.Request
@using ( Html.BeginForm( "Save", "Request", FormMethod.Post ))
{
@Html.DevExpress().PopupControl(
settings =>
{
settings.Name = "newRequest";
settings.CallbackRouteValues = new { Controller = "Request", Action = "GetRequestForm" };
settings.EnableClientSideAPI = true;
settings.Width = 450;
settings.ShowHeader = true;
settings.ShowShadow = true;
settings.PopupAnimationType = AnimationType.Fade;
settings.AllowDragging = true;
settings.Modal = true;
settings.SetContent( () =>
{
ViewContext.Writer.Write( "<div id = 'products'>" );
foreach(var product in Model.Products)
{
Html.RenderPartial( "ProductPartial", product );
}
ViewContext.Writer.Write( "</div>" );
//Total days field
@Html.DevExpress().SpinEdit(
cSettings =>
{
cSettings.Name = "numberOfProducts";
cSettings.Properties.EnableClientSideAPI = true;
cSettings.Width = 125;
cSettings.Properties.MinValue = 0;
cSettings.Properties.MaxValue = 100;
cSettings.ControlStyle.BackColor = System.Drawing.Color.FromArgb( 82, 82, 82 );
cSettings.ControlStyle.ForeColor = System.Drawing.Color.White;
} ).Bind( Model.NumberOfProducts ).GetHtml();
//POST BACK
@Html.DevExpress().Button( saveSett =>
{
saveSett.Name = "Save";
saveSett.Text = "Save";
saveSett.Width = 40;
saveSett.Height = 25;
saveSett.ControlStyle.CssClass = "button";
saveSett.Styles.EnableDefaultAppearance = false;
saveSett.EnableClientSideAPI = true;
saveSett.UseSubmitBehavior = true;
//saveSett.ClientSideEvents.Click = "function(s, e) { if(CheckValidation(s, e)) {} }";
} ).GetHtml();
} );
} ).GetHtml()
}
我的控制器动作:
public ActionResult GetRequestForm( )
{
//...
}
[HttpPost]
public ActionResult Save( Request request )
{
//...
}