Reputation: 11284
I am trying to show a particular element, $("#lblDischargeHeader").show();
using jquery from within a razor syntax block but the current code I have, razor is trying to treat as C# code.
@{
if (Model.Patient.PatientStatusType.Description == "Discharged")
{
$("#lblDischargeHeader").show();
<div id="DischargePanel" class="panel panel-danger" style="clear:both;">
<div class="panel-heading">Patient Discharged</div>
<div class="panel-body">
<table>
<tr>
<td><b>Date:</b></td><td>@Model.Patient.PatientDischarge.DischargeDate.ToShortDateString()</td>
<td><b>Reason:</b></td><td>@Model.Patient.PatientDischarge.Reason</td>
</tr>
</table>
</div>
</div>
}
}
I tried using the syntax: @:$("#lblDischargeHeader").show();
but all that does is render the line as text on my page.
Thank you for any assistance!
Upvotes: 0
Views: 171
Reputation: 245399
jQuery is JavaScript code that runs on the client.
C# runs server-side. You can't embed it server-side and have it run there. You'll need to hide the element on the server-side using C# and logic in your template or client-side with JavaScript (but no C#).
Upvotes: 1