我刚刚开始使用MVC,并试图构建一个样本,用于与jquery-mobile进行mvc交互的概念页面证明。我已经在这方面寻找答案,但我认为我还没有足够的知识来制定正确的查询。mvc + jqm actionlink html text issue
对我的看法,我想生成输出的功能就像这样(从JQM演示现场采样):
<ul data-role="listview" data-inset="true">
<li><a href="index.html">
<h3>Stephen Weber</h3>
<p><strong>You've been invited to a meeting at Filament Group in Boston, MA</strong></p>
<p>Hey Stephen, if you're available at 10am tomorrow, we've got a meeting with the jQuery team.</p>
<p class="ui-li-aside"><strong>6:24</strong>PM</p>
</a></li>
<li><a href="index.html">
<h3>jQuery Team</h3>
<p><strong>Boston Conference Planning</strong></p>
<p>In preparation for the upcoming conference in Boston, we need to start gathering a list of sponsors and speakers.</p>
<p class="ui-li-aside"><strong>9:18</strong>AM</p>
</a></li>
</ul>
所以,我喜欢这个工作吧:
@foreach (var item in Model) {
<li>
@Html.ActionLink(LargeExpandedMultiContentText, "Edit", new { id = item.SysID })
</li>
}
我的问题,我不知道一个简单的方法问,是,如何,在MVC术语中,我应该填充变量,以便由ActionLink()生成的href匹配我从jqm网站采样的样式?
我试过这个,虽然它几乎可以工作,但我确定它不是'正确'的方法,特别是当我得到一个拉动“史蒂文韦伯”和其他字符串的项目/模型...加上它编码的文本,但我敢肯定有一种方法来处理这么简单。
@foreach (var item in Model) {
<li>
@{ String txt = "<h3>Stephen Weber</h3><p><strong>You've been invited to a meeting at Filament Group in Boston, MA</strong></p><p>Hey Stephen, if you're available at 10am tomorrow, we've got a meeting with the jQuery team.</p> <p class=\"ui-li-aside\"><strong>6:24</strong>PM</p>";
}
@Html.ActionLink(txt, "Edit", new { id = item.SysID })
</li>
}
谢谢,我感谢您的帮助
布赖恩
感谢@ Html.Raw暗示......我知道我看到什么地方......你能回答,不管怎样,问题的关于做一个嵌套的代码块withing在foreach部分? – reidLinden 2012-04-30 12:53:32
如果可以,很乐意帮忙,但请重申问题的嵌套代码块部分。我不确定你指的是什么。 – DMulligan 2012-04-30 16:25:47
在我原来的帖子,第三代码块...在foreach中,我想知道如果这是正确的方式来处理这种想法,txt变量,并且如果这减少我字符串连接来构建出html ,或者如果有更多的MVC方式......为了记录,我将所有的代码都翻译成了你的推荐内容,而且事情看起来很隆重......谢谢! – reidLinden 2012-04-30 17:23:07