使用ASP.NET MVC3剃刀字符串连接 [英] String concatenation with ASP.NET MVC3 Razor
本文介绍了使用ASP.NET MVC3剃刀字符串连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图来连接在asp.net MVC 3剃须刀一个字符串,我开始有点sintax问题与我CSHTML。
i'm trying to concatenate a string in asp.net mvc 3 razor and i'm getting a little sintax problem with my cshtml.
我怎么为我的上一个foreach语句复选框一个ID,我的复选框应以CHK,什么开始cancatenate一个fieldon的ID,这样的事情:
i what to generate an id for my checkboxes on a foreach statement, and my checkboxes should start with "chk" and what to cancatenate a fieldon the ID, something like that:
<input type="checkbox" id="chk+@obj.field" />
但还是exampple为id属性的结果是:ID =CHK + 8
but or exampple the result for id attribute is: id="chk+8"
我如何才能得到一个结果为类似chk8?
how can i just get a result for something like "chk8"?
推荐答案
只要把你的变量旁边preFIX:
Just put your variable next to prefix:
<input type="checkbox" id="chk@(obj.field)" />
这篇关于使用ASP.NET MVC3剃刀字符串连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文