简体   繁体   English

将资源文件中的标题传递给剔除数据绑定属性

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

I have following html defined in my cshtml file我在我的 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>

i want to replace hardcode text "title1" and "title2" from resource file but i am really stuck on how to use Resources.Title1 and Resources.Title2.我想从资源文件中替换硬编码文本“title1”和“title2”,但我真的被困在如何使用 Resources.Title1 和 Resources.Title2 上。 I get so many syntax errors.我收到很多语法错误。 Any help?有什么帮助吗?

There are no title1 or title2 references, I'm also not entirely sure why you'd put so much html in the format, wouldn't <a href="#">@Html.Raw(Resources.title1)</a> work?没有 title1 或 title2 引用,我也不完全确定你为什么要在格式中放入这么多 html,不会<a href="#">@Html.Raw(Resources.title1)</a>工作? If there's really some formatting required due to a parameter in Resources.Test : <a href="#">@Html.Raw(string.Format(Resources.Test, 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