Reputation: 193
So basically what I am trying to accomplish is within my JQuery template I am conditionally adding html helper controls as applicable, what seems to be giving me trouble is the right razor syntax to use the client side value of $value.SomeUniqueId
as the ID for this server side generated control...
It will work if I use a static id as a literal like I am doing with the style; but I want to use an value I am feeding into the JQuery Template within and {{each items}}...{{/each}}
block
E.G.:
{{each items}}
{{if $value.IsAllowed }}
@Html.TextArea("txtSomeValue", new {style="width:80%", ID=$value.SomeUniqueId})
{{/if}}
{{/each}}
The offending line is: @Html.TextArea("txtSomeValue", new {style="width:80%", ID=$value.SomeUniqueId})
If I do this:@Html.TextArea("txtSomeValue", new {style="width:80%", ID="someID"})...
it works...
seem to be missing something obvious with the concatenation...
thanks in advance.
Upvotes: 2
Views: 1281
Reputation: 83366
I think you may need to set up this textarea manually—without Razor:
<textarea name="txtSomeValue" style="width:80%;">${value.SomeUniqueId}</textarea>
EDIT
Sorry, you want value.SomeUniqueId to be the textarea's id. This may work
<textarea name="txtSomeValue" id="${value.SomeUniqueId}" style="width:80%;"></textarea>
Upvotes: 2
Reputation: 2755
You should pass the value as a string:
{{each items}}
{{if $value.IsAllowed }}
@Html.TextArea("txtSomeValue", new {style="width:80%", ID="$value.SomeUniqueId"})
{{/if}}
{{/each}}
Upvotes: 0