Skip to content

Instantly share code, notes, and snippets.

@anova
Created October 14, 2020 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anova/bfcce3508a9052aad43066bece7eb3c0 to your computer and use it in GitHub Desktop.
Save anova/bfcce3508a9052aad43066bece7eb3c0 to your computer and use it in GitHub Desktop.
Pass a variable to partial (asp.net razor c# cshtml)
@{
double rating = 0;
if (this.ViewData.ContainsKey("Rating"))
{
rating = Convert.ToDouble(ViewData["Rating"]);
}
}
@Html.Partial("_Rating", new ViewDataDictionary { { "Rating", 2.5 }, { "CommentCount", 305 } })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment