{"id":2519,"date":"2022-08-30T15:25:32","date_gmt":"2022-08-30T15:25:32","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/01\/28\/how-to-remove-invalid-syntax-error-message-in-editing-razor-view-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:25:32","modified_gmt":"2022-08-30T15:25:32","slug":"how-to-remove-invalid-syntax-error-message-in-editing-razor-view-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/how-to-remove-invalid-syntax-error-message-in-editing-razor-view-collection-of-common-programming-errors\/","title":{"rendered":"How to remove invalid syntax error message in editing Razor view-Collection of common programming errors"},"content":{"rendered":"<p>In Razor ( in site master page and in views) javascript strings with dynamic content are used, like<\/p>\n<pre><code>@inherits ViewBase\n\n\n  $(function () {\n    $(\"#xx\").attr('title', @Html.Raw(Json.Encode(\".\")));\n<\/code><\/pre>\n<p>Microsoft Visual Studio Express for Web 2012 flags trailing parenthese as error:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/cvdPO.png\" \/><\/p>\n<p>How to fix this ?<\/p>\n<p>Construction \u00b4@Html.Raw(Json.Encode(Res.I(&#8220;somestring&#8221;)))\u00b4 is used in may places to dynamically translate texts for javascript. I() returns text im user languge. How to create some helper so that code is simllifid ? I created view common base class and added function there so that view contains only I(&#8220;somestring&#8221;) but this is not available in Razor master layout file Site.cshtml specified in \u00b4Layout = &#8220;~\/Views\/Shared\/Site.cshtml&#8221;\u00b4<\/p>\n<p>How to fix this error and use simple function I(&#8220;somestring&#8221;) which returs encoded javascript string ?<\/p>\n<p>ASP.NET MVC3 , C#, jquery, jquery ui are used.<\/p>\n<ol>\n<li>\n<p>Visual Studio&#8217;s Javascript language service does not recognize Razor markup within Javascript code blocks.<br \/>\nThese errors are false positives, and will not occur at runtime.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2014-01-28 10:03:04. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>In Razor ( in site master page and in views) javascript strings with dynamic content are used, like @inherits ViewBase $(function () { $(&#8220;#xx&#8221;).attr(&#8216;title&#8217;, @Html.Raw(Json.Encode(&#8220;.&#8221;))); Microsoft Visual Studio Express for Web 2012 flags trailing parenthese as error: How to fix this ? Construction \u00b4@Html.Raw(Json.Encode(Res.I(&#8220;somestring&#8221;)))\u00b4 is used in may places to dynamically translate texts for javascript. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2519","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2519","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2519"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2519\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2519"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2519"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}