The $
sign does not signal that Razor is switching to Html mode.
Put the script in the <text>
tags:
@if(!string.IsNullOrEmpty((TempData["notification-message"] as string))) { <text> $('#notification').jnotifyAddMessage({ text: '@TempData["notification-message"].ToString(), permanent: false }); </text> }
source share