c# - dynamically returning javascript function from controller and passing it to cshtml -


my controller is...

public actionresult createemailstep5() {     myviewmodel mvm = new myviewmodel();     mvm.mystringproperty = @"$(document).ready(function ($) {         $('#help').mytour(         {           tourtype: 'step',           overlayopacity: 0.5,           .......           .......         });     });"     return view(mvm); } 

what trying .cshtml like....

@model myproj.viewmodels.myviewmodel <script type="text/javascript">     model.mystringproperty; </script> 

i tried several things response.write, htmldecode , htmlencode... happening is... single quote being converted ascii " ' "

when trying...

response.write(@httputility.htmldecode(model.mystringproperty).tostring()); 

instead of

model.mystringproperty; 

in .cshtml giving erro $ not defined while have added required links

you want convert razor variable html 'type'

try using

@html.raw(model.mystringproperty) 

Comments