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 & lt; Script type = "text / javascript" src = "yourJSview.aspx" & gt;

Added as:

Set the content type to text / javascript , and enter your Javascript source < & Lt; Script & gt; Direct below & lt;% @ page directive without the tag.

Be careful not to get any intelligence for this in VS.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -