Arash
Arash

Reputation: 1826

trying to call function from an external JS file

i have a very simple asp.net code but my code doesnt make any sense and after run there would be nothing happen .

I'm using external java script file and trying to run my Script from my asp page and in the button object .

Its my asp code :

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="WebApplication2.test" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head ">
    <title></title>
    <script src="Script/Script_Validate.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server" >
<div>
    <asp:Button runat="server" Text="aaaaaa" OnClientClick="valid();"  />
</div>
</form>
</body>
</html>

Its my JS's file content :

function valid()
{
    alert("Hello! I am an alert box!!");
}

please help .

Upvotes: 0

Views: 895

Answers (1)

youyong
youyong

Reputation: 67

Your code works for me. Do you definitely have a "Script" folder? Is the name of the file correct? Do you have JavaScript enabled on your browser?

The only problem I can see with your code is your head tag has a single quotation mark ("). Maybe this should be runat="server"?

Upvotes: 1

Related Questions