views:

236

answers:

4

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.

+3  A: 

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

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>
rahul
I am sure, file is present at this path.
vaibhav
Maybe you're using master pages or something else and not quite sure where the files are launched.Simply open the file in the browser, press "view source" and use the JS path in the URL to see if it opens. Your syntax is (more or less) correct.
Faruz
yes I am using Master pages.
vaibhav
A: 

Use Fiddler to see what is happening. Then change the path accordingly. You will probably find you get a 404 error and the path is wrong.

RichardOD
+5  A: 

If your page is deeply pathed or might move around and your JS script is at "~/JS/Registration.js" of your web folder, you can try the following:

<script src='<%=ResolveClientUrl("~/JS/Registration.js") %>' 
type="text/javascript"></script>
o.k.w
+1  A: 

add like

<head runat="server">
<script src="Registration.js" type="text/javascript"></script>
</head>

OR can add in code behind.

Page.ClientScript.RegisterClientScriptInclude("Registration", ResolveUrl("~/js/Registration.js"));
Muhammad Akhtar