0

I want to include the script tag below using @HTML.Raw method:

<script type="text/javascript" src="~/App/durandal/amd/require.js" data-main="@Url.Content("~/App/main")"></script>

I am having problems including the data-main attribute.

This is what I have tried:

@Html.Raw("<script type='text/javascript' src='~/App/durandal/amd/require.js' data-main="@Url.Content("~/App/main")"></script>");
2
  • what is the reason to use @html.raw to load javascript file Commented Mar 27, 2014 at 14:51
  • I want to load that javascript file only when user is authenticated using Google+ Sign In. I get to know if the user is authenticated within a javascript function of a .cshtml file Commented Mar 27, 2014 at 15:01

1 Answer 1

1

If you want to achieve by using @html.raw, you can do something like this:

@Html.Raw(String.Format("<script type='text/javascript'
                         src='~/App/durandal/amd/require.js' 
                         data-main={0}></script>"
                        ,@Url.Content("~/App/main")))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.