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

Creating from code behind

6 Answers 199 Views
Window
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 25 Jul 2016, 10:38 AM

Hi,

I'm creating a RadWindow from the code behind and adding some controls via the ContentContainer.  When I run the page up I can see that the window exists on the page along with an inner div (called C) that contains all of my controls.  However when click the button to display the window it appears empty.  All formatting such as title, size behaviours etc are looking correct on the window.  It just has no content.

I have got ReloadOnShow set to false so there is no danger of it clearing the data.

Anything else that I might have missed that could cause this?  Not posting code at this stage as it is part of a very complex generation tool that I am working on and getting an appropriate small snippet of code would be tricky.  

Regards

Jon

 

6 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 25 Jul 2016, 11:32 AM

Hello Jon,

ReloadOnShow only works for content pages, not for the ContentTemplate.

Considering that you create everything dynamically, can you confirm that you recreate the controls with each postback? Here are two common issues:

  • This RadWindow is added to the Windows collection of a RadWindowManager. The manager will persist the instance, but I strongly advise that you move such RadWindows out of a manager, as noted at the end of this article: http://docs.telerik.com/devtools/aspnet-ajax/controls/window/getting-started/using-radwindow-as-controls-container.
  • The controls inside must be recreated after every postback, as with any dynamically created control in ASP.NET WebForms. Usually, the best place for this is the Page_Init event. If you create the RadWIndow after a postback event, then use another postback event to show it, it is likely that the controls inside are not created after the subsequent postback.

I also advise that you review the following article on using a RadWindow with AJAX: http://docs.telerik.com/devtools/aspnet-ajax/controls/window/how-to/how-to-use-radwindow-with-ajax.

Considering these details, I advise that you review the setup and see whether using a content page will not make things easier. You can see pros and cons for each mode in the following demo's description: http://demos.telerik.com/aspnet-ajax/window/examples/contenttemplatevsnavigateurl/defaultcs.aspx.

Regards,

Marin Bratanov
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Jon
Top achievements
Rank 1
answered on 25 Jul 2016, 11:44 AM

Hi Marin

Thanks for the comprehensive reply.  

I'd made sure it was stand alone, there is a window manager on the page but not attached to this window.  I get this isuse appear before any post backs / ajax calls so had ruled out that being a cause.  

I think I'll have to make a test page.

Good question re the content page.  Essentially I now have just one page on my site and each page is dynamically generated from class models.  It gives me great control over how the site works and I will be able to make changes to the base mechanisms a lot more easily.  But the setup is more complex.  The page in question is a dashboard style page where I want a filter popup window.  I could make it so that there is a mechanism built into the page to display the filter as a sub page I suppose - but it would probably increase the complexity considerably.

I'll create a support ticket if the test page doesn't tell me what is wrong.

Regards

Jon

 

0
Marin Bratanov
Telerik team
answered on 25 Jul 2016, 12:00 PM

Hello Jon,

I hope you fix this.

In the meantime—you can make a separate filter page and return data to the parent via JavaScript (see the OnClientClose event). Once you have this event and data in the page, you can initiate any request you need and store the data in a hidden field, or pass as an argument to a service, whatever you are using.

Or, you can store information in the Session, Cache, file or a database in the content page and initiate a generic postback that will read this data on the server.

Regards,

Marin Bratanov
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Jon
Top achievements
Rank 1
answered on 25 Jul 2016, 12:09 PM

Hi Marin,

Many thanks, I'm sure that it will be something very basic in the end.  

Yes thats more or less what I was thinking.  In some respects it would make for a faster page as the filter pages will potentially have some cascading combos (always fun - not!).  They are using ajax so having the page run on its own would be a good plan.  

If the page is done like that then when it closes the iframe would still be on the page for me to grab the field data via JS wouldn't it? 

Regards

Jon

0
Marin Bratanov
Telerik team
answered on 25 Jul 2016, 12:21 PM

Hi Jon,

In such a case perhaps it will be a good idea to separate the filter in its own page so the main page does not go through the postback sequence while filtering.

As for getting the data—yes, the iframe remains on the page, just the popup gets hidden via CSS.

The only thing that can change this is the DestroyOnClose property which removes the RadWindow from the DOM when it is closed. It defaults to true, so if you do not use it explicitly, this will not happen

The following article shows how you can call a function in the content page to return the needed data: http://docs.telerik.com/devtools/aspnet-ajax/controls/window/how-to/calling-functions-in-windows.

Regards,

Marin Bratanov
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Jon
Top achievements
Rank 1
answered on 26 Jul 2016, 08:19 AM
Morning Marin,

Well switching to have it in a new page was easy enough thanks to the way my page is being done.  A spin off benefit :)

Oddly this didn't work straight away but all of a sudden it started working.  I initially noticed that it was fine in Chrome but failed in IE.

Thanks for the help with this.

Regards

Jon
Tags
Window
Asked by
Jon
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Jon
Top achievements
Rank 1
Share this question
or