Reputation: 10888
I have a wizard with a number of steps, for each step I have a user control being added. For one of the step, I want to run jQuery script on page load, so following is added in user control .ascx file -
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="PropertyEntryWizard10HipEpcQuestions.ascx.cs" Inherits="PropertyInstructionEntryWizard.PropertyEntryWizard09HipEpcQuestions" %>
<%@ Register Src="~/Controls/Properties/HipManager.ascx" TagName="hip_manager" TagPrefix="rt" %>
<script type="text/javascript">
$(document).ready(function () {
alert('HipManager ready');
});
</script>
<h2>EPC</h2>
<rt:hip_manager ID="ctlHipMan" runat="server" ValidationGroup="Wizard" />
But it's not firing on page load,
instead when I do a manual re-load from the browser button, it does get run and I get the alert.
NOTE: I also found out that if I move the script from this user control to main .aspx page, it works fine. My user control is using lots of PeterBlum controls, so I am not sure if any script associated with them is causing the issue.
Any idea, what I am missing?
Thank you!
Upvotes: 1
Views: 12719
Reputation: 173
Have you tried using the pageLoad() function instead of $(document).ready()?
Which one you use really depends on what you are trying to do in the long run with the code, but take a look here as this is a really good explanation of which one you should be using in different situations:
http://encosia.com/document-ready-and-pageload-are-not-the-same/
Upvotes: 3