in my javascript I'm trying to build a string that will be html and inside that string i also want to use MVC's Html.Action helper. I want to append this to some <div> element. Works fine if i take out the line @Html.Action. Am i going about this right or is this done some other way?
function Conditionalpartialview(MyParamID) {
var html =
'<br />' +
'<div id="SurveyQuestionConditionalLogic_' + MyParamID + '">' +
'<span id="SurveyLogicIDsarr_' + MyParamID + '" >' + MyParamID + '</span>' +
'@Html.Action("ControlerActionMethod", "Home", new { ID = MyParamID })' +
'</div>'
$("div").append(html);
}
@Html.Action()is razor code and its parsed on the server before its sent to the view.Actionhelper which rendered by server, you can use AJAX call to an action method which returning view/partial view.