Firing jquery on an OnClientClick event in a separate file from aspx page

I have an aspx file with a button:

 <asp:TableRow HorizontalAlign="Left">
    <asp:TableCell HorizontalAlign="Center" ColumnSpan="2">
        <asp:Button ID="ButtonSaveUser" runat="server" Text="Register" OnClick="ButtonSaveUser_Click"
            OnClientClick="chkForm()" />

I want to be able to store my jquery in a seperate file to make it cleaner and easier to work with. So, I include my link to this file (Scripts/RegistrationValidation.js) which follows:

$(document).ready(function() {

chkForm();   });

I read that the button's OnClientClick event should link to this code which it does. But, when I set a break point on the first line it doesn't get past the first line that waits for the DOM to load.

BTW, I've tried this on IE9 and Chrome with the same issue.

Is it the DOM not loading? I don't know what it is.



Firstly,the jquery or javascrip is web client script. That is, the following script is separate with C# server script.

$(document).ready(function() {

chkForm();   });

You should debug the script and consider whether the jquery script is loaded or not . e.g.

$(document).ready(function() {


Secondly,you can learn the firebug extension on the browse of firefox or chrome. The extension can help you to find directly whether the script is loaded or not .

While JavaScript provides the load event for executing code when a page is rendered, this event does not get triggered until all assets such as images have been completely received.

$(document).ready(function(){}); works only when DOM is fully loaded. What is the problem?

Need Your Help

Visual Studio JavaScript Intelliense for VB generated controls

javascript visual-studio-2012 intellisense

We have a user control system in place that allows us to create user controls which generate the HTML and JS necessary for the user control to function. The initial values or options are set in VB/...

Javascript unknown number of arguments

javascript variables arguments

in my project, I register different functions (having different number of arguments) as listeners to a number of events. When the event takes place, I need to fire the associated function. I receiv...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.