第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

實(shí)體字符串未在 C# 中解碼

實(shí)體字符串未在 C# 中解碼

C#
回首憶惘然 2021-11-07 19:14:40
我在 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 如下所示:&lt;input type=&quot;text&quot; name=&quot;username&quot; id=&quot;username&quot; class=&quot;form-control&quot; placeholder=&quot;Enter your name&quot;  /&gt;我不知道為什么它不解碼字符串。有任何想法嗎?
查看完整描述

1 回答

?
拉丁的傳說

TA貢獻(xiàn)1789條經(jīng)驗(yàn) 獲得超8個贊

您正在嘗試顯示 html,但問題不在于方法,而在于您沒有在 mvc 中正確打印它。像這里建議的那樣做:

@Html.Raw(RenderField())


查看完整回答
反對 回復(fù) 2021-11-07
  • 1 回答
  • 0 關(guān)注
  • 194 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號