RadMenu + RadWindow in a Compiled Control Class Library

3 posts, 0 answers
  1. ATS
    ATS avatar
    49 posts
    Member since:
    Mar 2007

    Posted 03 Jul 2011 Link to this post

    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. Georgi Tunev
    Georgi Tunev avatar
    7207 posts

    Posted 04 Jul 2011 Link to this post

    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.

  3. ATS
    ATS avatar
    49 posts
    Member since:
    Mar 2007

    Posted 05 Jul 2011 Link to this post

    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!
Back to Top