Ejemplo n.º 1
0
        /// <summary>
        /// 获取数字框的客户端的脚本参数配置
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public static string GetNumberBoxScript(NumberOptions options, string id)
        {
            if (options == null)
            {
                options = new NumberOptions();
            }
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("");
            sb.Append(WebConsts.ScriptBegin);
            sb.Append("new song.numberbox('#" + id + "',{");
            sb.AppendFormat("allowDecimal:{0},allowNegative:{1}", options.AllowDecimal.ToString().ToLower(), options.AllowNegative.ToString().ToLower());
            sb.Append(",maxValue:" + options.MaxValue);
            sb.Append(",minValue:" + options.MinValue);
            if (options.Precision.HasValue)
            {
                sb.Append(",precision:" + options.Precision.Value);
            }
            if (!string.IsNullOrEmpty(options.OnEnter))
            {
                sb.Append(",onEnter:" + options.OnEnter);
            }
            sb.Append("});");
            sb.Append(WebConsts.ScriptEnd);
            return(sb.ToString());
        }
Ejemplo n.º 2
0
 public static MvcHtmlString NumberBoxFor <TModel, TProperty>(
     this HtmlHelper <TModel> helper,
     Expression <Func <TModel, TProperty> > expression,
     NumberOptions options
     )
 {
     return(NumberBoxFor(helper, expression, options, null));
 }
Ejemplo n.º 3
0
        public static MvcHtmlString NumberBoxFor <TModel, TProperty>(
            this HtmlHelper <TModel> helper,
            Expression <Func <TModel, TProperty> > expression,
            NumberOptions options,
            object htmlAttributes
            )
        {
            // IDictionary<string, object> attrs = SetAttributes(options, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
            string        name = helper.ViewData.TemplateInfo.GetFullHtmlFieldName(ExpressionHelper.GetExpressionText(expression));
            StringBuilder sb   = new StringBuilder();

            sb.Append(helper.TextBoxFor(expression, htmlAttributes).ToString());
            sb.AppendLine(GetNumberBoxScript(options, name));
            return(MvcHtmlString.Create(sb.ToString()));
        }
Ejemplo n.º 4
0
        public static MvcHtmlString NumberBox(
            this HtmlHelper helper,
            string name,
            object value,
            NumberOptions options,
            object htmlAttributes
            )
        {
            // IDictionary<string, object> attrs = SetAttributes(options, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
            StringBuilder sb = new StringBuilder();

            sb.Append(helper.TextBox(name, value, htmlAttributes).ToString());
            sb.AppendLine(GetNumberBoxScript(options, name));
            return(MvcHtmlString.Create(sb.ToString()));
        }
Ejemplo n.º 5
0
 public static MvcHtmlString NumberBox(this HtmlHelper helper, string name, object value, NumberOptions options)
 {
     return(NumberBox(helper, name, value, options, null));
 }