Purusartha
Purusartha

Reputation: 1010

How to assign text value to control for bool model

This may be a simple syntax issue, but I have a (bool) model and I want to assign the value attribute to custom text based on the state of the model. Following is my code where I have been stuck for a while now:

<input type="button" id="btnLikeContent" name="btnLikeContent" value=@{(Model.IsUserLikesContent) ? "Unlike" : "Like"} />

The intellisense error I get is "The attribute requires a value, if the value is enclosed in quotation marks, the quotation marks must match"

Any help will be much appreciated!

Upvotes: 1

Views: 83

Answers (2)

Jaykumar Patel
Jaykumar Patel

Reputation: 27614

Try this,

<input type="button" id="btnLikeContent" name="btnLikeContent" value='@(Model.IsUserLikesContent ? "Unlike" : "Like")' />

Upvotes: 2

Felix
Felix

Reputation: 38102

Try to wrap your value in quote:

value='@{(Model.IsUserLikesContent) ? "Unlike" : "Like"}'

Upvotes: 0

Related Questions