Client side script behaviors not working after AJAX postback

I'm trying out ATLAS and trying to create a simple calendar popup that populates a text field.  The problem is, after the date is selected and the textbox gets populated, the calendar won't popup again.

The calendar popup/hide is handled using client side ATLAS calls and the population using UpdatePanels and server side calls.

Can someone help me out and try to get the popup functionality to work after a date has been selected? Here's my code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"/>
        <atlas:UpdatePanel ID="upCalendar" runat="server">
        <ContentTemplate>
            <asp:TextBox ID="txtDate" runat="server" Font-Bold="True" Font-Names="Verdana" Font-Size="10px"></asp:TextBox>
            <asp:HyperLink ID="hlCalendar" runat="server" Font-Names="Verdana" Font-Size="10px">></asp:HyperLink><div style="visibility: hidden; display:none;" id="CalendarPopup">
                <asp:Calendar ID="calPopup" runat="server" Font-Names="Verdana" Font-Size="10px" OnSelectionChanged="calPopup_SelectionChanged"></asp:Calendar>
            </div>
        </ContentTemplate>
        </atlas:UpdatePanel>
    </form>
    <script type="text/xml-script">
        <page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
            <references>
            </references>
            <components>
            <control id="CalendarPopup">
                    <behaviors>
                        <popupBehavior id="calendarPopupBehavior" parentElement="txtDate" positioningMode="BottomLeft" />
                    </behaviors>
            </control>
            <hyperLink id="hlCalendar">
                    <behaviors>
                        <clickBehavior click="CalendarPopup">
                            <click>
                                <invokeMethod target="calendarPopupBehavior" method="show" />
                            </click>
                        </clickBehavior>
                    </behaviors>
            </hyperLink>
            <hyperLink id="calPopup">
                    <behaviors>
                        <hoverBehavior hoverElement="CalendarPopup">
                            <unhover>
                                <invokeMethod target="calendarPopupBehavior" method="hide" />
                            </unhover>
                            <hover>
                                <invokeMethod target="calendarPopupBehavior" method="show" />
                            </hover>
                        </hoverBehavior>
                    </behaviors>
            </hyperLink>
            </components>
        </page>
    </script>
</body>
</html>

Thanks in advance!
0
robfarmer
6/16/2006 6:59:34 PM
asp.net.ajax-ui 9760 articles. 0 followers. Follow

5 Replies
773 Views

Similar Articles

[PageSpeed] 46

Hi,

you can't associate Atlas controls to server controls inside an UpdatePanel in this way, because after the first partial postback the Atlas controls will be disposed and not re-initialized.

The solution is to write an Atlas-enabled control that renders the xml-script dynamically. In this way the xml-script will be rendered again on each partial postback and the Atlas control will be recreated correctly.

Alessandro Gallo | Blog | My book: ASP.NET AJAX In Action
0
Garbin
6/17/2006 12:03:45 PM
As Garbin has already pointed out, you will effectively lose the events when a partial postback occurs. This is a known issue and unfortunately there is no fix apart from what Garbin has suggested (which can be a tad more work than is worth justifying) or to see if you can re-arrange your page such that you can aviod this issue.
- Paul Glavich
Blog: http://weblogs.asp.net/pglavich
0
Glav
6/19/2006 6:26:59 AM
Thank you both for your replies.  Glav, you said this is a known issue; is Microsoft going to address the issue or is this the intended design and functionality?

Rob
0
robfarmer
6/19/2006 1:03:00 PM

Its hard for me to say. Only Microsoft can really say whether this will be fixed at RTM. Anything is possible. I do know it wont be fixed in the short term so dont bank on it anytime soon.

Personally, I'd be looking at ways around it rather than banking on a fix. Sorry I can't give you anymore than that.


- Paul Glavich
Blog: http://weblogs.asp.net/pglavich
0
Glav
6/19/2006 1:32:21 PM
Hi,

robfarmer, if you are a bit familiar with Javascript, you can easily write an Atlas extender to implement your popup calendar.

Alessandro Gallo | Blog | My book: ASP.NET AJAX In Action
0
Garbin
6/19/2006 7:03:42 PM
Reply: