سؤال

i'm facing a little problem here :

i have an aspx page that contains an update panel that has a place holder (in its content template) containing different userControls that show/hide depending on certain conditions.

One of them has a long script inside with an initializing function that has controls retrieved with server tags ( <% #myCtrl.ClientID%>) to get values etc.. and the thing is that when i call this function once the updatepanel finishes updating, it simply says it's undefined..

as if my userControl script wasn't seen at all,

Here is my aspx page with the "initializeFees" function call when the update is finished:

 <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"
            EnablePageMethods="true">
<asp:UpdatePanel runat="server">
        <ContentTemplate>
            <script type="text/javascript">     
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(initializeFees);

            </script>
        <div class="Registration_ProgressContent">
            <uc3:Ctrl_RegistrationProgress ID="Ctrl_RegistrationProgress1" runat="server" OnSelectedIndexChanged="changeStep" />
        </div>
    </div>
    <div class="Registration_StepContent">
        <asp:PlaceHolder runat="server">
            <uc1:Ctrl_RegistrationGeneral ID="Ctrl_RegistrationGeneral1" runat="server" Visible="False" />
            <uc4:Ctrl_RegistrationFee ID="Ctrl_RegistrationFee1" runat="server" Visible="False" />

and here is my "uc4:Ctrl_RegistrationFee" html code :

<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="Ctrl_RegistrationFee.ascx.vb"
    Inherits="MDSInscription.Ctrl_RegistrationFee" %>
<script type="text/javascript">

    //Validateurs
    var valTeam;
    var valEmail;
    var imgName;

    function initializeFees() {
        valTeam = $('#valCreateTeamName');
        valEmail = $('#valCreateEmail');

        $("#accordion").accordion({
        //activate: function (event, ui) {
        //    //                validateSelection();
        //}
    });

with the code behind (VB.NET.....#joy..) :

Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender

    ScriptManager.RegisterClientScriptBlock(Me, Page.GetType(), "Init", "initializeFees();", True)

End Sub

this is the code i got after searching for more than an hour, and i get the following error :

Uncaught ReferenceError: initializeFees is not defined 

if you feel like you can help, thanx !

هل كانت مفيدة؟

المحلول

problem solved with the following script, that i put outside the update panel :

    function pageLoad() {
        $(".datepicker").datepicker({
            changeMonth: true,
            changeYear: true,
            minDate: "-100Y",
            maxDate: "-15Y",
            dateFormat: "dd/mm/yy",
            yearRange: "1913:2300"
        });
        //more Code executed on each postback from the update panel ...
        }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top