0

I have a masterpage and a default page in a project in VS2010. I am trying to import a javascript file.

If I import the .js file the project compiles and loads but the whole browser screen is blank. If I comment out the javascript import line the page displays correctly.

Below is the two versions of the 'view source' of the page...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>

</title>
    <script type="text/javascript" src="Include/jquery-1.5.1.min.js"/>
    
</head>
<body >
    <form name="aspnetForm" method="post" action="Default.aspx" id="aspnetForm">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTY1NDU2MTA1MmRkGAEJI5+bs1wRmkRMJFsLRxPPhT7Z7NvrME9cYWjxI7s=" />
</div>

    <div>
        
new test

    </div>
    </form>
</body>
</html>

The code above results in a blank web page. Whereare...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>

</title>
    <!--<script type="text/javascript" src="Include/jquery-1.5.1.min.js"/>-->
    
</head>
<body >
    <form name="aspnetForm" method="post" action="Default.aspx" id="aspnetForm">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTY1NDU2MTA1MmRkGAEJI5+bs1wRmkRMJFsLRxPPhT7Z7NvrME9cYWjxI7s=" />
</div>

    <div>
        
new test

    </div>
    </form>
</body>
</html>

This code displays correctly with the words 'new test' at the top of the screen as expected.

The only difference is the the script import line is commented out is the secod block of code.

This is a bare bones test with just the masterpage and a content page. there is no other code or markup than the script import and the test words in the content page.

It does not matter what javascript file is imported the result is the same.

There is one other strange bit. this is a project that was upgraded from VS 2008 and there is another masterpage in the project that has multiple javascript imports and all work correctly. The problem seems to be with the newly created masterpages in VS 2010.

I haven't tried copying the old (vs2008) masterpage and modifying it but this is not the point. I need to be able to create masterpages within VS2010.

Does anyone have any ideas?

Regrds

Ray

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by rgudgeon
0

That maybe happens because page and master are not in the same folder. To solve this case register script file on page load.

Edited by jugosoft: n/a

0

<script> tags need a closing </script> tag. /> is not enough.

Hericles is correct. Adding the closing tag correctly fixed the problem - Thanks

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.