This is a migrated thread and some comments may be shown as answers.

Edit Window Template in Window manager

7 Answers 55 Views
Window
This is a migrated thread and some comments may be shown as answers.
Peter Viau
Top achievements
Rank 1
Peter Viau asked on 10 Feb 2014, 09:34 PM
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?

7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 11 Feb 2014, 06:21 AM
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.
0
Marin Bratanov
Telerik team
answered on 11 Feb 2014, 11:54 AM
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.
0
Peter Viau
Top achievements
Rank 1
answered on 11 Feb 2014, 01:09 PM
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();
0
Peter Viau
Top achievements
Rank 1
answered on 11 Feb 2014, 02:26 PM
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();
0
Peter Viau
Top achievements
Rank 1
answered on 11 Feb 2014, 03:34 PM
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?

0
Marin Bratanov
Telerik team
answered on 12 Feb 2014, 12:14 PM
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.
0
Peter Viau
Top achievements
Rank 1
answered on 12 Feb 2014, 01:08 PM
That seems to work.

Thanks!
Tags
Window
Asked by
Peter Viau
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Marin Bratanov
Telerik team
Peter Viau
Top achievements
Rank 1
Share this question
or