1

I'm building a web application using MVC3 and I'm wondering what the etiquette is in regards to having javascript (whether it's embedded or external) in the master page, and then having javascript that pertains to an individual child page.

For example, is it fine to have an embedded section for javascript in the maser page, and then another one in the child page, such that there will be two sets of tags when the page is rendered in the browser?

What is the generally accepted way to do this? Thank you.

2 Answers 2

2

That is acceptable. There's no problem.

The alternative way to execute javascript code that runs on only 1 page would be to add javascript code within your master .js file, and, on each page load, check

if (this.href == "http://.............") 
{ 
    /* execute unique js */ 
}
Sign up to request clarification or add additional context in comments.

1 Comment

I'll just wait on a bit more responses, and if this is the general consensus, then you'll be the accepted answer. Thanks.
1

Refer to the following url: http://blogs.msdn.com/b/marcinon/archive/2010/12/15/razor-nested-layouts-and-redefined-sections.aspx

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.