Esempio n. 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack)
     {
         //允许 value包含逗号的写法
         RequestToModel.SetIsUnvalidatedFrom = key =>
         {
             var    formArray = Request.Form.GetValues(key).Select(it => it == null ? it : it.Replace(",", RequestToModel.COMMAS)).ToArray();
             string reval     = string.Join(",", formArray);
             return(reval);
         };
         var list = RequestToModel.GetListByForm <RTModel>();
     }
 }
Esempio n. 2
0
        public JsonResult SaveAttrsAndEvents(string htmlId, int addressId, int languageId, string category, string eleName, int?ApiId, string Description)
        {
            PageFactoryDomain _pfd = new PageFactoryDomain(_db);

            //允许Form有特殊字符 如 < ,等
            RequestToModel.SetIsUnvalidatedFrom = key =>
            {
                var val = Request.Unvalidated.Form.GetValues(key);
                if (val.IsNullOrEmpty())
                {
                    return(null);
                }
                var formArray = val.Select(it => it == null ? it : it.Replace(",", RequestToModel.COMMAS)).ToArray();
                return(string.Join(",", formArray));
            };

            //锁住静态对象
            lock (RequestToModel.SetIsUnvalidatedFrom)
            {
                var             elementType = _pfd.GetElementIdByCategory(category);
                SysBest_Element insObj      = new SysBest_Element()
                {
                    AddressId   = addressId,
                    CreateTime  = DateTime.Now,
                    ElementType = elementType,
                    LanguageId  = languageId,
                    EleName     = eleName,
                    Html_Id     = htmlId,
                    ApiId       = ApiId,
                    Description = Description,
                    Founder     = "聪哥"
                };
                //允许特殊字符
                var formEvents = RequestToModel.GetListByForm <ElementEvent>("event.");
                var formAttrs  = RequestToModel.GetListByForm <ElementAttr>("attr.");
                //用完清空
                RequestToModel.SetIsUnvalidatedFrom = null;
                var reval = SaveAttrsAndEvents_temp(elementType, insObj, addressId, formAttrs, formEvents);
                ActionResultModel <string> model = new ActionResultModel <string>();
                model.isSuccess = reval;
                return(Json(model));
            }
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                //设置允许 value中 包含逗号的写法
                RequestToModel.SetIsUnvalidatedFrom = key =>
                {
                    var    formArray = Request.Form.GetValues(key).Select(it => it == null ? it : it.Replace(",", RequestToModel.COMMAS)).ToArray();
                    string reval     = string.Join(",", formArray);
                    return(reval);
                };

                //表单提交获取单个对象
                // var category = RequestToModel.GetSingleForm<RTModel>();
                //表单提交获取多个对象
                //只获取表单中name= form12.xxx的数据
                List <RTModel> categoryLists = RequestToModel.GetListByForm <RTModel>("form12.");
                //获取所有的数据 属性需要保持一致
                List <RTModel> categoryLists2 = RequestToModel.GetListByForm <RTModel>();

                var list = RequestToModel.GetformToModel <RTModel>();
            }
        }