RadWindow not displaying from within user control

2 posts, 1 answers
  1. Tayonee
    Tayonee avatar
    52 posts
    Member since:
    Nov 2006

    Posted 02 Jan 2015 Link to this post

    I have a very simple test scenario that I am trying to work out and have found a very strange behavior that is keeping it from working.

    Here is my basic scenario: I want to display a modal window with a single user control in it. The user control only contains a RadGrid for editing some basic data. If I put a copy of the RadWindow code on a test host aspx page, it works just fine. If I put the *exact same code* into a new bare bones user control, and desposit that on a different test page, the RadWindow no longer displays.

    Here is my RadWindow definition:

    <telerik:RadWindow ID="modalPopup" runat="server" Modal="true" OffsetElementID="main" OpenerElementID="btnShowWindow" Height="525px" Width="525px" InitialBehaviors="Resize">
        <ContentTemplate>
            <uc3:MissingLocationPremiumEditor ID="ctlMissingLocationPremiumEditor" runat="server" />
        </ContentTemplate>
    </telerik:RadWindow>
    <asp:Button ID="btnShowWindow" runat="server" Text="Show Window" />

    If I put this on my test page, it works fine. If I put it into this user control (with no code behind), it no longer displays. When I click the button the screen flickers and nothing shows.

    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="windowdummy.ascx.vb" Inherits="McRating.windowdummy" %>
    <%@ Register Src="../controls/ClientPicker.ascx" TagName="ClientPicker" TagPrefix="uc2" %>
    <%@ Register Src="../protected/controls/ClientDetail.ascx" TagName="ClientDetail" TagPrefix="uc1" %>
    <%@ Register Src="../protected/controls/MissingLocationPremiumEditor.ascx" TagName="MissingLocationPremiumEditor" TagPrefix="uc3" %>
    <telerik:RadWindow ID="modalPopup" runat="server" Modal="true" OffsetElementID="main" OpenerElementID="btnShowWindow" Height="525px" Width="525px" InitialBehaviors="Resize">
        <ContentTemplate>
            <uc3:MissingLocationPremiumEditor ID="ctlMissingLocationPremiumEditor" runat="server" />
        </ContentTemplate>
    </telerik:RadWindow>
    <asp:Button ID="btnShowWindow" runat="server" Text="Show Window" />

    Why would I get different behaviors?? My test pages have nothing more than a RadScriptManager on them because I was trying to strip this all done to the absolute bare minimum to get it working.

    That is the basic issue, but I did a little more extensive troubleshooting. I created a test page that had the basic RadWindow code input right on it, and right below it, a reference to the user control - effectively giving me both ways of doing it on the same page. 

    Here is where things got interesting. If I clicked the user control embedded version, the screen flashed and nothing else happened. It doesn't matter if I click that button first or not. Once I click the local page version of the RadWindow then I see the modal dialog as I should. HOWEVER, I accidentally noticed that in fact the user control embedded version is actually right underneath the one I see. If I move the local embedded RadWindow out of the way, I can see the window created by the user control, as shown in the attached image.

    So, what is going on here anyway, and how can I fix it?
  2. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 05 Jan 2015 Link to this post

    Hello,

    To successfully use the OpenerElementID and OffsetElementID properties, they must point to the IDs of the HTML elements on the rendered page. Server controls like buttons, however, can have different IDs when rendered because of the automatic ID generation by ASP when INaming containers (like user controls or master pages) are involved. You can see how you can use these properties with the ClientIDs of the desired server controls here: http://demos.telerik.com/aspnet-ajax/window/examples/openandposition/defaultcs.aspx.

    I also advise that you examine the following two articles to get a better view of the ways to reference and open a RadWindow:

    What happens in your case is the following:

    • On a blank aspx page the button IDs do not change so the snippet works as expected.
    • In a user control the button has a different ID so RadWindow cannot capture it when the ClientID of the button is not used.
    • When the user control with these snippets and the bare snippets are added to the page you get a button with the simple ID, so both RadWindows attach to it so you see both.


    Regards,

    Marin Bratanov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top