Popup Control Extender

Last post 07-17-2006 2:35 PM by David Anson. 32 replies.

Sort Posts:

  • Popup Control Extender

    04-19-2006, 9:14 AM
    • Member
      5 point Member
    • marcellops
    • Member since 04-18-2006, 10:38 PM
    • Posts 1

    I'm using the Popup Control Extender within calendar and DetailsView.

    I put the calendar inside a popup control extender and add in inside EditTemplate DetailsView.

    When I click in textbox for using a calendar and select one date, raise the message: "Assertion Failed: Duplicate of use id "txtDate"_PopupControl" for object type "AtlasControlToolkit.PopupControlBehavior"".

    I've tryed  disable debug=false in web.config, but a selected date not set a textbox.

    Both inside a one UpdatePanel. 

  • Re: Popup Control Extender

    04-19-2006, 2:51 PM
    • Contributor
      4,198 point Contributor
    • Ted Glaza [MSFT]
    • Member since 04-12-2006, 11:51 PM
    • Microsoft
    • Posts 847
    • AspNetTeam
    Hi marcellops,

    You should checkout the post at http://forums.asp.net/thread/1256999.aspx where a similar issue was raised.  I think this might help you.

    Thanks,
    Ted
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Popup Control Extender

    04-20-2006, 10:50 AM
    • Member
      5 point Member
    • marcellops
    • Member since 04-18-2006, 10:38 PM
    • Posts 1

    Hi Ted,

     

    I've read a similar issue, but I use a PopupControl inside a EditTemplate from DetailsView, and this error only raise in this set.

  • Re: Popup Control Extender

    04-25-2006, 11:46 AM
    • Member
      34 point Member
    • Rammesses
    • Member since 04-20-2006, 1:46 PM
    • Posts 10

    I've had a similar error, but when I had two instances of the same user control on a page where that user control in turn had a PopupControlExtender embedded in it.

    It appears that the PopupControlExtender uses the ID property of the PopupControlProperties class to generate client-side code that includes the TargetControlID directly, rather than finding the ClientID of the target control.

    This means that you can't have a control replicated on a page (in a repeater, datagrid, or within user controls that are used more than once) without getting this ID conflict.

    I've currently trying to work up a suitable patch, tho' it looks like the fix will require a change to ExtenderBase class as well as the PopupControlExtender class.

  • Re: Popup Control Extender - UPDATE & FIX

    04-26-2006, 5:47 AM
    • Member
      34 point Member
    • Rammesses
    • Member since 04-20-2006, 1:46 PM
    • Posts 10
    Rammesses:

    I've currently trying to work up a suitable patch, tho' it looks like the fix will require a change to ExtenderBase class as well as the PopupControlExtender class.

    Well, I managed to avoid needing to patch ExtenderBase, but it's a fairly hairy hack, involving changes to PopupExtenderControl.cs and PopupExtenderProperties.cs

    In PopupExtenderControl.cs, add the following highlighted line to the thing method:

            /// <summary>
            /// OnLoad override to register a startup script for each PopupControl behavior
            /// </summary>
            /// <param name="e">arguments</param>
            protected override void OnLoad(EventArgs e)
            {
                base.OnLoad(e);
                foreach (PopupControlProperties popupControlProperties in TargetProperties)
                {
                    // add a back reference to allow correct client id naming
                    popupControlProperties.Parent = this;
                    string key = string.Format(CultureInfo.CurrentCulture, "{0}_PopupControl_Close", popupControlProperties.ID);
                    string script = string.Format(CultureInfo.CurrentCulture, "var popupControlBehavior = Sys.Application.findObject('{0}'); if (popupControlBehavior) {{ popupControlBehavior.close(); }}", popupControlProperties.ID);
                    Page.ClientScript.RegisterStartupScript(this.GetType(), key, script, true);
                }
            }

     Then in PopupExtenderProperties.cs, change the ID property as shown:

            /// <summary>
            /// Private control ID for the PopupControlBehavior
            /// </summary>
            [Browsable(false)]
            [EditorBrowsable(EditorBrowsableState.Never)]
            [DisplayName("id")]  // Note: Case is important here because it needs to match the "Atlas" default "id" property
            [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1706:ShortAcronymsShouldBeUppercase", Justification = "Following Atlas pattern")]
            public string ID
            {
                get
                {
                    return string.Format(CultureInfo.CurrentCulture, "{0}_PopupControl", GetClientIDForTarget(TargetControlID));
                }
                set
                {
                    // Do nothing
                    SuppressUnusedParameterWarning(value);
                }
            }

     Finally, add the following property and helper method to the same file (PopupControlExtender.cs):

            /// <summary>
            /// Get / set our parent control
            /// </summary>
            /// <remarks>
            /// i.e. the PopupExtender to which this PopupExtenderControl belongs.
            /// </remarks>
            internal Control Parent
            {
                get { return parentControl; }
                set { parentControl = value; }
            }
    	
            /// <summary>
            /// Return the ClientID for the target control 
            /// </summary>
            /// <remarks>
            /// This relies on the Parent property of this PopupExtenderProperty
            /// being set - if not, then the passed Target (Control) ID will be used.
            /// This can cause problems if the Extender is used in repeaters, datagrids
            /// or usercontrols, etc.
            /// </remarks>
            /// <param name="theTargetID"></param>
            /// <returns></returns>
            private string GetClientIDForTarget(string theTargetID)
            {
                string theClientID = theTargetID;
                if (this.Parent != null)
                {
                    // the parent of this Property will be the extender, so we need
                    // to jump up 2 levels to search for the target control
                    Control theControl = this.Parent.Parent.FindControl(theTargetID);
                    if (theControl != null)
                    {
                        theClientID = theControl.ClientID;
                    }
                }
                return theClientID;
            }

    The code should fall back to the current (broken ;-) ) functionality if the target control cannot be resolved. I guess the GetClientIDForTarget method could be a bit more agressive and recursively look for the target control - at the moment, it's a restriction that the target must be resolvable by the FindControl method of the parent of the extender.

    Hope this helps.

    Joel

  • Re: Popup Control Extender - UPDATE & FIX

    04-26-2006, 2:20 PM
    • Star
      8,710 point Star
    • David Anson
    • Member since 04-11-2006, 1:39 AM
    • Microsoft
    • Posts 1,842
    • AspNetTeam
    Fantastic, thanks Rammesses! I've added a note to look at incorporating something like this into a future release. :)

    http://blogs.msdn.com/delay

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Popup Control Extender - UPDATE & FIX

    04-28-2006, 8:31 AM
    • Member
      427 point Member
    • niallhannon
    • Member since 03-23-2006, 2:50 PM
    • Posts 125

    Hi,

    I've been trying to follow this issue with the Popupextender control as applied to a calendar control. Are we saying that it doesnt work currently if you have a gridview on the page?

    I am getting the same errors as other users posted.

    Any ideas when this will be fixed?

    Thanks

    N

  • Re: Popup Control Extender - UPDATE & FIX

    04-28-2006, 1:42 PM
    • Member
      90 point Member
    • tripletdad
    • Member since 11-19-2005, 3:14 PM
    • Posts 18
    I have tried without any success to implement the sample PopupControl Demonstration code within a FormView's InsertItemTemplate. I can get a calendar control (within a Panel and UpdatePanel) to display ("popup"), but can not get the selcted date to "commit" to the TextBox control. Consider the following block of code... Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) PopupControlExtender1.Commit(txtServiceDate, Calendar1.SelectedDate.ToShortDateString()) End Sub When "PopupControlExtender1" is within a FormView's InsertItemTemplate control, there is no exposure to PopupControlExtender1. You get the error (blue underline) stating that it is undefined. The only way I can find this control is to use FormView.FindControl("PopupControlExtender1") If I pull all the TextBoxes (within a Table) out of the FormView - it works fine. I can "see" PopupControlExtender1! The bad thing about that is I loose ALL of my databindings... and would have to wire that all up by hand. I would love to see an example of the PopupControlExtender working as one would expect within a FormView and/or a DetailsView control. I would expect we'd have similar issues when using MultiView / View controls.
  • Re: Popup Control Extender - UPDATE & FIX

    05-01-2006, 8:36 PM
    • Star
      8,710 point Star
    • David Anson
    • Member since 04-11-2006, 1:39 AM
    • Microsoft
    • Posts 1,842
    • AspNetTeam

    FYI: The problem of conflicting automatically-generated PopupControl (or TextBoxWatermark) IDs when used in a repeater, etc., should be fixed in the next release.

    Thanks!


    http://blogs.msdn.com/delay

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Popup Control Extender - UPDATE & FIX

    05-02-2006, 4:02 PM
    • Member
      90 point Member
    • tripletdad
    • Member since 11-19-2005, 3:14 PM
    • Posts 18
    I guess the next question would be an estimated ETA for the next release then??
  • Re: Popup Control Extender - UPDATE & FIX

    05-02-2006, 4:15 PM
    • Star
      8,710 point Star
    • David Anson
    • Member since 04-11-2006, 1:39 AM
    • Microsoft
    • Posts 1,842
    • AspNetTeam
    No promises, but later this week seems within reach!

    http://blogs.msdn.com/delay

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Popup Control Extender - UPDATE & FIX

    05-09-2006, 11:02 AM
    • Member
      427 point Member
    • niallhannon
    • Member since 03-23-2006, 2:50 PM
    • Posts 125
    Did this fix make it into the recent release of the toolkit, it seems it didnt as I still get the same errors with the popup control extender and the calendar control and gridviews.
  • Re: Popup Control Extender - UPDATE & FIX

    05-09-2006, 2:16 PM
    • Star
      8,710 point Star
    • David Anson
    • Member since 04-11-2006, 1:39 AM
    • Microsoft
    • Posts 1,842
    • AspNetTeam

    The ID properties of PopupControl and TextBoxWatermark in the refresh use the new GetUniqueID method which is based on the target control's ClientID and should therefore avoid naming collisions.

    If folks are still having problems, I'm afraid I don't understand the issue. Could someone please post a simple sample using the latest Toolkit code that demonstrates the problem?

    Thanks!


    http://blogs.msdn.com/delay

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Popup Control Extender - UPDATE & FIX

    05-10-2006, 5:56 AM
    • Member
      427 point Member
    • niallhannon
    • Member since 03-23-2006, 2:50 PM
    • Posts 125

    This must be due to my own fault, I probably dont understand the best way to set up the atals update panels.

    See this simple example below....

    The control that triggers the popup calendar is also within an update panel. I think this is the issue. It works fine is the trigger control is outside of an update panel. Is this the correct behaviour?

    Thanks for your help.

    <%

    @ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %>

    <%

    @ Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="AtlasToolkit" %>

    <%

    @ Register Assembly="RJS.Web.WebControl.PopCalendar" Namespace="RJS.Web.WebControl" TagPrefix="rjs" %>

    <

    atlas:scriptmanager ID="scriptmanager" runat=server EnablePartialRendering="true" />

    <!

    DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <

    html xmlns="http://www.w3.org/1999/xhtml" >

    <

    head runat="server">

    <title>Untitled Page</title>

    </

    head>

    <

    body>

    <form id="form1" runat="server">

    <atlas:UpdatePanel ID="UpdatePanel2" runat="server">

    <ContentTemplate>

    <asp:TextBox ID="DateTextBox" runat="server" Width="80"></asp:TextBox>

    </ContentTemplate>

    </atlas:UpdatePanel>

    <atlas:UpdatePanel ID="UpdatePanel1" runat="server">

    <ContentTemplate>

    <atlasToolkit:PopupControlExtender ID="PopupControlExtender1" runat="server">

    <atlasToolkit:PopupControlProperties TargetControlID="DateTextBox" PopupControlID="Calendar1" Position="Bottom" />

    </atlasToolkit:PopupControlExtender>

    <center>

    <asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="#999999" CellPadding="1" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" Width="160px" >

    <SelectedDayStyle BackColor="#666666" Font-Bold="True" ForeColor="White" />

    <TodayDayStyle BackColor="#CCCCCC" ForeColor="Black" />

    <SelectorStyle BackColor="#CCCCCC" />

    <WeekendDayStyle BackColor="#FFFFCC" />

    <OtherMonthDayStyle ForeColor="#808080" />

    <NextPrevStyle VerticalAlign="Bottom" />

    <DayHeaderStyle BackColor="#CCCCCC" Font-Bold="True" Font-Size="7pt" />

    <TitleStyle BackColor="#999999" BorderColor="Black" Font-Bold="True" />

    </asp:Calendar>

    </center>

    </ContentTemplate>

    </atlas:UpdatePanel>

    </form>

    </

    body>

    </

    html>
  • Re: Popup Control Extender - UPDATE & FIX

    05-10-2006, 8:07 AM
    • Member
      427 point Member
    • niallhannon
    • Member since 03-23-2006, 2:50 PM
    • Posts 125
    So, is it a case that the control that opens the popup control can never be within an update panel?
Page 1 of 3 (33 items) 1 2 3 Next >