How to insert resulting HTML from a partial view into javascript code?
<p>I am using grid-stack for drag/drop functionality in my asp.net mvc web application. </p>

<p>I have an "Add Widget" button....</p>

<pre><code>&lt;button class="btn btn-white btn-primary" id="addwidget" type="submit"&gt;Add Widget&lt;/button&gt;
</code></pre>

<p>I also have a bunch of MVC5 partial pages (Razor), one file for each "widget". When I click the "Add Widget" button I want to insert a widget onto the page. Right now here is the js code for the click event of the button...</p>

<pre><code>        $('#addwidget')
        .click(function () {
            var grid = $('.grid-stack').data('gridstack');
            var partialView = @Html.Partial("~/Views/Widgets/_MyImportLatest.cshtml").ToHtmlString();
            grid.addWidget($('&lt;div class="ibox-content" style="height:160px;"&gt;' + partialView + '&lt;/div&gt;'), 0, 0, 3, 2, true);
        });
</code></pre>

<p>Yes, that's Razor code mixed in with js. And, unfortunately it doesn't like partialView at all, as you may have guessed. </p>

<p>I'm trying to basically get the resulting partial view into a string so that I can use that html string in the addWidget function. If I hardcode partialView this works and the widget is added. </p>

<p>Any ideas? Thanks!</p>