Search code examples
asp.netjavascriptmaster-pages

How to include Javascript file in Asp.Net page


I want to do some client side validation using javascript in ASP.NET page.

I tried using

<script src="../../../JS/Registration.js" language="javascript" type="text/javascript" />

but its not working. Please help.


Solution

  • Probably the file is not in the path specified. '../../../' will move 3 step up to the directory in which the page is located and look for the js file in a folder named JS.

    Also the language attribute is Deprecated.

    See Scripts:

    18.2.1 The SCRIPT element

    language = cdata [CI]

    Deprecated. This attribute specifies the scripting language of the contents of this element. Its value is an identifier for the language, but since these identifiers are not standard, this attribute has been deprecated in favor of type.

    Edit

    Try changing

    <script src="../../../JS/Registration.js" language="javascript" type="text/javascript" /> 
    

    to

    <script src="../../../JS/Registration.js" language="javascript" type="text/javascript"></script>