public static MvcHtmlString bsEditFormSaveButton(this HtmlHelper helper, Action<bsButton> settings) { if (!(helper.ViewData.Model is BaseEditFormModel)) throw new Exception(nameof(bsEditFormSaveButton)+" может использоваться только с моделью типа '"+nameof(BaseEditFormModel)+"'"); var model = helper.ViewData.Model as BaseEditFormModel; var button = new bsButton(model); button.ButtonStyle = bsButtonStyle.Success; button.Bind_OnClick(model.SaveButtonClick); button.Bind_Text(()=>model.GetSaveButtonText()); button.Bind_Disabled(() => model.GetSaveButtonDisabled()); button.Bind_OnTrueClass(() => model.IsInsertMode, "btn-success"); button.Bind_OnFalseClass(() => model.IsInsertMode, "btn-info"); button.AddStyle("min-width", "80px"); settings(button); (helper.ViewData.Model as BaseModel).Helper = helper; //var script = new StringBuilder(); //var html = new StringBuilder(); return new MvcHtmlString(button.GetHtml()); }
public static MvcHtmlString bsEditFormCancelButton(this HtmlHelper helper, Action<bsButton> settings) { if (!(helper.ViewData.Model is BaseEditFormModel)) throw new Exception(nameof(bsEditFormSaveButton)+" может использоваться только с моделью типа '"+nameof(BaseEditFormModel)+"'"); var model = helper.ViewData.Model as BaseEditFormModel; var button = new bsButton(model); button.AddClass("modal-cancel-button"); button.ButtonStyle = bsButtonStyle.Default; button.Bind_OnClick(model.CancelButtonClick); button.Bind_Text(()=>model.GetCancelButtonText()); settings(button); (helper.ViewData.Model as BaseModel).Helper = helper; var script = new StringBuilder(); var html = new StringBuilder(); return new MvcHtmlString(button.GetHtml()); }
public static MvcHtmlString bsMessageDialogOkButton(this HtmlHelper helper, Action<bsButton> settings) { if (!(helper.ViewData.Model is MessageDialogModel)) throw new Exception(nameof(bsEditFormSaveButton)+" может использоваться только с моделью типа '"+nameof(MessageDialogModel) +"'"); var model = helper.ViewData.Model as MessageDialogModel; var button = new bsButton(model); button.ButtonStyle = bsButtonStyle.Success; button.Bind_OnClick(model.OkButtonClick); button.Text = "Ok"; button.AddStyle("min-width", "80px"); settings(button); (helper.ViewData.Model as BaseModel).Helper = helper; //var script = new StringBuilder(); //var html = new StringBuilder(); return new MvcHtmlString(button.GetHtml()); //return new MvcHtmlString(button.EmitScriptAndHtml(script, html)); }
//public static MvcHtmlString bsButton(this HtmlHelper helper, bsButtonSettings settings) //{ // (helper.ViewData.Model as BaseModel).Helper = helper; // return new MvcHtmlString("");// new bsButton(helper.ViewData.Model, settings).GetHtml()); //} //public static MvcHtmlString bsButton(this HtmlHelper helper, Action<bsButtonSettings> settings) //{ // (helper.ViewData.Model as BaseModel).Helper = helper; // return new MvcHtmlString("");// new bsButton(helper.ViewData.Model, settings).GetHtml()); //} public static MvcHtmlString bsButton(this HtmlHelper helper, Action<bsButton> settings) { var Settings = new bsButton(helper.ViewData.Model as BaseModel); settings(Settings); (helper.ViewData.Model as BaseModel).Helper = helper; //var script = new StringBuilder(); //var html = new StringBuilder(); return new MvcHtmlString(Settings.GetHtml()); }