Pirzada
Pirzada

Reputation: 4713

MVC3 Razor Ternary issue

How can I make this work?

title="@(Request.IsAuthenticated ? ("Manage Your Appointments," Model.User.FirstName Model.User.LastName) : "Book Your Appointment")"

Upvotes: 0

Views: 188

Answers (1)

John Allers
John Allers

Reputation: 3122

I'm assuming title is an html attribute. In that case, you can probably use an apostrophe for the outer string.

Update: I completely overlooked FirstName and LastName in my original answer. Assuming that those should be concatenated.

title='@(Request.IsAuthenticated
         ? ("Manage Your Appointments, " + Model.User.FirstName + " " + Model.User.LastName)
         : "Book Your Appointment")'

Upvotes: 1

Related Questions