我在 SQL Server 數(shù)據(jù)庫的文本列中輸入了以下 JSon:{ "tag" : { "string" : "<input type=\"text\" [attributes] />", "attributes" : { "name" : { "required" : true, "label" : "Field name", "description" : "Use only letters and minus sign", "expert" : false }, "id" : { "required" : false, "label" : "Field identifier", "description" : "Use only letters and minus sign", "expert" : true }, "class" : { "required" : false, "default" : "form-control", "label" : "Field styles", "description" : "These must exist in the stylesheet, leave blank if you don't know about them", "expert" : true }, "required" : { "required" : false, "allowed" : [ "required", "" ], "label" : "Is the field required?", "description" : "If the user must enter a value in this field, use the word required", "expert" : true },好的,所以基本上這個 JSon 包含輸入字段的描述及其所有可能的屬性。標(biāo)簽鍵里面的字符串鍵,是字段的基本結(jié)構(gòu)。在另一個表中,我基于該結(jié)構(gòu)創(chuàng)建了一個字段,它在 JSon 中有以下信息:{ "tag" : { "name" : "username", "id" : "username", "class" : "form-control", "placeholder" : "Enter your name" }}使用 C# 我想將字段呈現(xiàn)為表單:public string RenderField() { var data = JObject.Parse(this.Data); //Data is the field that contains the definition of the field var structure = JObject.Parse(this.FieldTypes.Datos); // FieldTypes defines the structure of each possible field type string tagHtml = structure["tag"]["string"].ToString(); // This is the basic form of a form field foreach(JProperty key in data["tag"]) { tagHtml = tagHtml.Replace("[attributes]", key.Name + "=\"" + key.Value + "\" [attributes]"); } return WebUtility.HtmlDecode(tagHtml).Replace("[attributes]", ""); }基本上一切都按預(yù)期工作,但由于某種原因,該字段未顯示,但其 htmlentities 如下所示:<input type="text" name="username" id="username" class="form-control" placeholder="Enter your name" />我不知道為什么它不解碼字符串。有任何想法嗎?
- 1 回答
- 0 關(guān)注
- 194 瀏覽
添加回答
舉報
0/150
提交
取消