jquery - Html.Partial in Javascript -


i'm trying render partial view within javascript code. partial view contains js codes well, it's kendo window.

this code, changes suggested in post:

var win = "@html.partial("_genericwindow").tostring().replace(environment.newline, "").replace(" ", "")";  $(".body-content").append(win); 

but code renders string in page:

<divid="7067ea1a-0425-44a6-99d3-aefb37f088ed"></div><script> jquery(function(){jquery("#7067ea1a-0425-44a6-99d3-aefb37f088ed").kendowindow({"modal":false,"iframe":false,"draggable":true,"scrollable":true,"pinned":false,"title":null,"resizable":true,"content":null,"actions":["close","minimize","refresh"]});});</script>

and finally, partial view:

@{     var winid = guid.newguid().tostring(); }  @(html.kendo().window()     .name(winid)     .draggable()     .resizable()     .actions(actions => actions.close().minimize().refresh()) ) 

the issue mvc preventing injecting raw html response stream.

you can modify code introducing @html.raw() tell mvc want inject raw html

ex..

var win = "@html.raw(@html.partial("_genericwindow").tostring().replace(environment.newline, "").replace(" ", ""))";  $(".body-content").append(win); 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -