Javascript within a repeater within a updatepanel problem

Last post 02-18-2008 2:33 PM by kirchi. 1 replies.

Sort Posts:

  • Javascript within a repeater within a updatepanel problem

    02-18-2008, 10:12 AM
    • Loading...
    • DottyWelsh
    • Joined on 02-21-2007, 9:18 AM
    • Wales
    • Posts 40

    The basic problem is that the javascript to popup the calendar on the user control works when the usercontrol is placed inside a repeater. However if you then wrap the repeater inside and AJAX update panel it works initially. But the calendar no longer pops up, once a partial postback has been initiated on the panel. In our particular case a postback is initiated when we change the number of items we want to see in the repeater, via a drop down list.  Here’s an example of the repeater inside a panel:

     

        <asp:UpdatePanel ID="updCentresPanel" runat="server" UpdateMode="Conditional">

            <ContentTemplate>

                <asp:Repeater ID="uxCentresRepeater" runat="server">

                    <ItemTemplate>

                        <travelinfo:Centre ID="uxCentre" runat="server" />

                    </ItemTemplate>

                </asp:Repeater>

            </ContentTemplate>

            <Triggers>

                <asp:AsyncPostBackTrigger ControlID="uxNumberCentresDropDown" EventName="SelectedIndexChanged" />

            </Triggers>

        </asp:UpdatePanel>

     Cheers in advance

  • Re: Javascript within a repeater within a updatepanel problem

    02-18-2008, 2:33 PM
    Answer
    • Loading...
    • kirchi
    • Joined on 03-07-2007, 2:47 AM
    • Posts 328

    Hi DottyWelsh,

    register script that is needed to attach a calendar as follows:

     

     bool registered = false;
                    ScriptManager Smgr = ScriptManager.GetCurrent(Page);
                    if (Smgr != null)
                    {
                        if (Smgr.IsInAsyncPostBack)
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), ClientID, InitScript, true);
                            registered = true;
                        }
                    }
                if (!registered)
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), ClientID, InitScript, true);
                }
     

    here "InitScript" is the variable of type String, that contains javascript you need to register.

    Hope this helps

    My blog: http://blog.devarchive.net
    My samples: http://devarchive.net
Page 1 of 1 (2 items)
Microsoft Communities
Page view counter