0

How can I use c# code in a Javascript statement?

This is my code:

document.getElementById('part1').innerHTML = '' +
'@Html.Partial("SelectCustomer.Views")'
' Views';

@Html.Partial("SelectCustomer.Views") and <%= and %> do not work

MAESTRO_DE
  • 433
  • 2
  • 17

1 Answers1

1
 @Html.Raw("document.getElementById('part1').innerHTML = '' +
 @Html.Partial("SelectCustomer.Views")
 ' Views';");

Don't have razor project on hand to test it. Might need to remove the @ from the second Html.

MrVentzi
  • 639
  • 3
  • 13