簡體   English   中英

將資源文件中的標題傳遞給剔除數據綁定屬性

[英]passing title from resource file to knockout data-bind attribute

我在我的 cshtml 文件中定義了以下 html

               <span>
                    @Html.Raw(String.Format(Resources.Test,
                   "<a href=\"#\" role=\"button\" style=\"color: #458ccc; \" data-container=\"body\" data-trigger=\"hover\" data-placement=\"auto right\" data-bind=\"bootstrapPopover: { title: 'title1', content: 'something', template: '<div class=&quot;popover&quot; style=&quot;padding:0px;&quot; role=&quot;tooltip&quot;><div class=&quot;arrow&quot;></div><h3 class=&quot;popover-title&quot; style=&quot;background-color:#458ccc; color:#FFF; &quot;></h3><div class=&quot;popover-content&quot;></div></div>' }\">name1<span class=\"fa fa-question-circle-o\" style=\"font-size:1em;\"></span></a>",
                   "<a href=\"#\" role=\"button\" style=\"color: #458ccc; \" data-container=\"body\" data-trigger=\"hover\" data-placement=\"auto right\" data-bind=\"bootstrapPopover: { title: 'title2', content: 'anything', template: '<div class=&quot;popover&quot; style=&quot;padding:0px;&quot; role=&quot;tooltip&quot;><div class=&quot;arrow&quot;></div><h3 class=&quot;popover-title&quot; style=&quot;background-color:#458ccc; color:#FFF; &quot;></h3><div class=&quot;popover-content&quot;></div></div>' }\">name2<span class=\"fa fa-question-circle-o\" style=\"font-size:1em;\"></span></a>"))
                </span>

我想從資源文件中替換硬編碼文本“title1”和“title2”,但我真的被困在如何使用 Resources.Title1 和 Resources.Title2 上。 我收到很多語法錯誤。 有什么幫助嗎?

沒有 title1 或 title2 引用,我也不完全確定你為什么要在格式中放入這么多 html,不會<a href="#">@Html.Raw(Resources.title1)</a>工作? 如果由於Resources.Test中的參數確實需要一些格式: <a href="#">@Html.Raw(string.Format(Resources.Test, Resources.title1))</a>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM