asp.net mvc - Using Inline C# inside Javascript File in MVC Framework -
I am trying to get inline c # to work in my javascript files using the MVC framework. I've made this a little test code
$ (document) .ready (function () {alert (& lt;% = ViewData ["message"]%> & gt;);}) ;
When this code is used to look inside it works perfectly. When I exit my aspx scene and try it in a javascript file, then I get an invalid XML character. I think this is a design in the MVC framework, but I can not find any content on the Web on this.
Has anyone received Inline C # to work in Javascript files using the MVC framework?
As others have said, C # is not being processed by the server.
There will be a separate view for a possible solution that uses the same model and outputs to Javascript, the reference can be found on your Added as: Set the content type to Be careful not to get any intelligence for this in VS. & lt; Script type = "text / javascript" src = "yourJSview.aspx" & gt;
text / javascript
, and enter your Javascript source < & Lt; Script & gt; Direct below
tag. & lt;% @ page
directive without the
Comments
Post a Comment