code/Athena0.0.1/common/Util/Web/HtmlDialog.cs

(开头部分) 8KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace System.Web.Mvc.Html
{
    public static class DialogExtensions
    {
        public static IDisposable Dialog(this HtmlHelper htmlHelper, int width)
        {
            DialogSetting set = new DialogSetting(width);
            return Dialog(htmlHelper, set);
        }
        public static IDisposable Dialog(this HtmlHelper htmlHelper, string withModel, string id, int width)
        {
            DialogSetting set = new DialogSetting(withModel, id, width);
            return Dialog(htmlHelper, set);
        }
        public static IDisposable Dialog(this HtmlHelper htmlHelper, DialogSetting set = null)
        {
            HtmlDialog dialog = new HtmlDialog(htmlHelper.ViewContext, set);
            dialog.BeginDialog();
            return dialog;
        }


        public static HtmlString BeginDialog(this HtmlHelper htmlHelper, int width)
        {
            DialogSetting set = new DialogSetting(width);
            return BeginDialog(htmlHelper, set);
        }
        public static HtmlString BeginDialog(this HtmlHelper htmlHelper, string withModel, string id, int width)
        {
            DialogSetting set = new DialogSetting(withModel, id, width);
            return BeginDialog(htmlHelper, set);
        }
        public static HtmlString BeginDialog(this HtmlHelper htmlHelper, DialogSetting set = null)
        {
            StringBuilder htmlBuilder = new StringBuilder();

            if (set == null)
                set = DialogSetting.DefaultSetting;

            htmlBuilder.CAppend("<div data-bind=\"with:{0}\">", set.WithModel).AppendLine();
            htmlBuilder.CAppend("    <div data-bind=\"display:IsShow()\" class=\"modal fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"myModalLabel\" aria-hidden=\"true\" id=\"{0}\" data-backdrop=\"false\" data-keyboard=\"true\">", set.Id).AppendLine();
            htmlBuilder.CAppend("        <div class=\"modal-dialog\" style=\"width:{0}px;\">", set.Width.ToString()).AppendLine();
            htmlBuilder.CAppend("            <div class=\"modal-content\" style=\"width:{0}px;\">", set.Width.ToString()).AppendLine();

            /* header */
            htmlBuilder.CAppend("                <div class=\"modal-header\">").AppendLine();
            htmlBuilder.CAppend("                    <label data-bind=\"text:Title\"></label>").AppendLine();
            htmlBuilder.CAppend("                    <button type=\"button\" class=\"close\" data-dismiss=\"modal\" data-bind=\"click:function(){ IsShow(false);}\"><span aria-hidden=\"true\">&times;</span></button>").AppendLine();
            htmlBuilder.CAppend("                </div>").AppendLine();

            return new HtmlString(htmlBuilder.ToString());
        }
        public static HtmlString EndDialog(this HtmlHelper htmlHelper)
        {
后面还有 140 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。