c# - Trying to save output from RenderPartial to a Javascript variable and use it later -


in create view:

<script type="text/javascript">     var tabcontent = "<% html.renderpartial("productedit", new web.model.product()); %>"; </script> 

unfortunately seems break. @ least quotes (") aren't escaped (\"). how "inject" results of renderpartial js?

instead of storing variable, can put in placeholder, this:

<div id="tabcontent" style="display: none;">   <% html.renderpartial("productedit", new web.model.product()); %> </div> 

then when want use it, via .innerhtml, this:

var myvar = document.getelementbyid('tabcontent').innerhtml; 

this useful in other scenarios, if want clone it, etc...it depends how intend use it, i've found more useful approach in cases.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -