Click here to Skip to main content
15,910,234 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to run a simple jquery function on an ascx web control, shown below. when the page runs the alert is not displayed . I am using VS2010 SP1. Can any one help

XML
<%@ Control Language="vb" AutoEventWireup="false" CodeFile="inc_header.ascx.vb" Inherits="inc_header" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>

<script type="text/javascript" src="scripts/jquery-1.6.3.js">
    $(document).ready (function () {
        alert('test');

    });

</script>
Posted
Comments
Anuja Pawar Indore 20-Jan-12 3:20am    
Why you are writing $(document).ready, as control will be called in some aspx page.
Muralikrishna8811 20-Jan-12 5:39am    
you wan to invoke something on control loading
then its better to write on onload of control tag

1 solution

JavaScript
$(document).ready(function () {}); 
will only run after a full postback occurs (when the DOM is reloaded). I assume you are adding the controls via another AJAX method (in that case document.ready will not fire. You can use the AJAX framework event pageLoad(sender, args) which will fire after both a callback and postback. You can use it like so ..

JavaScript
function pageLoad(sender, args) {
        if (args.get_isPartialLoad()) {
            setAutoTimer();
            getData();
        }
    }
 
Share this answer
 
Comments
Tech Code Freak 20-Jan-12 6:37am    
5up!
Truly said!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900