Edit Window Template in Window manager

8 posts, 0 answers
  1. Peter Viau
    Peter Viau avatar
    8 posts
    Member since:
    Jan 2010

    Posted 10 Feb 2014 Link to this post

    I added a Windows Manager so that I could close windows from an external JavaScript file which works fine.

    My issue is that I still have work to do with the contents of the individual Window Templates but after I add the windows to the Windows Manager I can't see the windows in Visual Studio anymore, How do I edit the Window Templates after adding them to the window manager since I don't see an "Edit Template menu item in Windows Manager?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 11 Feb 2014 in reply to Peter Viau Link to this post

    Hi Peter Viau,

    Please try to set the VisibleOnPageLoad Property of either RadWindowManager or RadWindow  as true to display the content inside the RadWindow. There is no EditTemplate in RadWindow, you can edit the Controls inside the ContentTemplate of RadWindow. Please have a look in to the sample code snippet which works fine at my end.

    ASPX:
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" VisibleOnPageLoad="true">
        <Windows>
            <telerik:RadWindow ID="RadWindow1" runat="server">
                <ContentTemplate>
                    <%--You can edit the textBox value--%>
                    <telerik:RadTextBox ID="RadTextBox1" runat="server" Text="Demo">
                    </telerik:RadTextBox>
                </ContentTemplate>
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>

    Let me know if you have any concern.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 11 Feb 2014 Link to this post

    Hi guys,

    I would advise against using the VisibleOnPageLoad property for showing a RadWIndow once and this sticky thread explains the better process: http://www.telerik.com/community/forums/aspnet-ajax/window/opening-radwindow-from-the-server.aspx.

    On using the ContentTemplate of a RadWIndow that is inside the Windows collection of a RadWIndowManager - I advise against this, because this mode is not entirely compatible with the main logic of the manager. I would advise using these windows standalone on the page and you can use the Sys.Application.Load event to store references to them in a global object/array that you can use from your external files. This blog post can help you get started with this: http://blogs.telerik.com/jefffritz/posts/13-01-21/simplify-javascript-control-references-in-asp.net-webforms.

    To edit an individual RadWindow's CotentTemplate in design mode of VS you should first select the control (this cannot be done via the RadWindowManager collection editor), then show its Smart Tag, then select Edit - this will enable editing for the template. Once you are done, select End Editing from the RadWIndow Smart Tag.


    Regards,
    Marin Bratanov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
  5. Peter Viau
    Peter Viau avatar
    8 posts
    Member since:
    Jan 2010

    Posted 11 Feb 2014 in reply to Marin Bratanov Link to this post

    The only reason I was thinking of using a window manager is that I use an external .js file and this code does not work to open or close the window with the error "JavaScript runtime error: Unable to get property 'show' of undefined or null reference":

    ​ var oWnd = $find("<%= pcContractDetails.ClientID %>");

    oWnd.show();

    but this code does work when I use a window manager:

    ​var oWnd = oManager.getWindowByName("pcContractDetails");
    oWnd.close();
  6. Peter Viau
    Peter Viau avatar
    8 posts
    Member since:
    Jan 2010

    Posted 11 Feb 2014 Link to this post

    Something new.

    I tried using this code and it works the first time but when I try to open the window a second time I get a null value for "oWnd"


    ​function ShowNewContracts() {

    varContract = $telerik.$("[id$='pcContractDetails']").attr("id");

    var oWnd = $find(varContract);
    oWnd.show();
  7. Peter Viau
    Peter Viau avatar
    8 posts
    Member since:
    Jan 2010

    Posted 11 Feb 2014 Link to this post

    I found a work around although I'd rather use the actual name of the window this works.

    varContract = $telerik.$("[id$='confirmItemWindow']").attr("id");

    var oWnd = $find(varContract);


    The first time I call the function oWnd returns "ctl00_MainContent_confirmItemWindow" which opens the window.

    The second time I call the function oWnd returns "RadWindowWrapper_ctl00_MainContent_confirmItemWindow" which does not open the window.

    If I change the call to:

    $find("ctl00_MainContent_confirmItemWindow").show();

    It works everytime.

    Any idea why this is?

  8. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 12 Feb 2014 Link to this post

    Hello Peter,

    RadWindow renders its popup element with JavaScript only when it is first shown. This popup element has an ID that is constructed in the following way:
    RadWindowWrapper_<control ClientID>

    This popup (div) is the first child of the <form> element, so the jQuery selector will find and return that first.

    So, you can simply make sure this prefix is removed:
    varContract = $telerik.$("[id$='confirmItemWindow']").attr("id").replace("RadWindowWrapper_", "");
    var oWnd = $find(varContract);

    In this way you can avoid hardcoding ClientIDs, which is an error prone approach.

    Regards,
    Marin Bratanov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
  9. Peter Viau
    Peter Viau avatar
    8 posts
    Member since:
    Jan 2010

    Posted 12 Feb 2014 in reply to Marin Bratanov Link to this post

    That seems to work.

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