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

RadMenu + RadWindow in a Compiled Control Class Library

2 Answers 70 Views
Window
This is a migrated thread and some comments may be shown as answers.
ATS
Top achievements
Rank 1
ATS asked on 03 Jul 2011, 06:21 PM
I've created a class library for various custom controls that we use a lot, and it works great. I've gotten pretty comfortable designing the UI and all of that in pure code-behind. My latest control is an image rotator that grabs various information about each image from the EXIF data and displays it. I want to take it to the next level, so that the user can right-click on an image and click a menu item that pops up an edit window and change the EXIF data. I have each individual piece working, but I can't seem to get it to all go together. I have two thoughts on how I could accomplish this.

  1. Use a separate "page" for the edit window (use the NavigateUrl on the RadWindow) and pass the image name on the URL. This is how I would normally do it - use the image name from the querystring to populate the current data, let the user change it, refresh the control on close. The problem with this approach is that I'm completely stuck figuring out how to generate a complete ASP.NET web form entirely in a class - in other words, create a page with the .aspx.cs file and no .aspx file. I can't even seem to get any guidance from Google on this one! I tried to create a class called EditForm.cs that inherits from System.Web.UI.Page and generating the form dynamically, then adding an httpHandler to my web.config to map "editForm.axd" to that class. It all works, but the "page" comes up empty when you to go it. Even if you just go directly to the page (http://localhost/MyNamespace.EditForm.axd), it's completely empty.
  2. Use a ContentTemplate for the edit window instead. Unfortunately, this approach is nearly undocumented. When I click the RadMenu item, I can get the image name that the user clicked from javascript (by using OnClientItemClicked), but then there's no way to get that back to the RadWindow on the server side. So I tried setting a session variable in the ItemClick server-side event. I'd rather not have to post-back just to get the image name, but it is what it is. The problem with this approach is that I have no idea when to populate my RadWindow based on the data I have. The OnLoad event fires on the main page's Page_Load, so that's not an option. And there doesn't seem to be any kind of an OnShow type event server-side.

Is there an option I'm missing? Remember that all of this is getting compiled into a single class-library dll, so there are no designer files, no aspx files, etc. Pure code. Any guidance would be greatly appreciated!

2 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 04 Jul 2011, 01:06 PM
Hi JT,

I would suggest to go with the second approach (using a content template) and wrap the controls in an ajax panel (make sure that the RadWindow is declared outside of any other update panels, so you won't get into an "ajax panel inside another ajax panel" problem). This way, when you make a postback inside the content (in the panel), you will be able to read the data from the server.


All the best,
Georgi Tunev
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
ATS
Top achievements
Rank 1
answered on 05 Jul 2011, 06:40 PM
So you're saying when the user clicks the Edit EXIF Data context menu item, that the OnClientItemClicked function would pass the image name as an argument to the ajax request. Then I could get that argument in the AjaxRequest() event on the server side, and populate my form then. And then of course do more processing when the user clicks a Save or Submit button or something... Is that right? It sounds good - I'm going to go give it a shot. Thanks Georgi, I'll let you know what happens!
Tags
Window
Asked by
ATS
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
ATS
Top achievements
Rank 1
Share this question
or