Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
        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());
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        //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());
        }