|
Rank: Member Groups: Member
Joined: 1/26/2009 Posts: 13
|
Hi there,
I'm testing the EO.Web components for a project I'm working on currently and it looks very good so far.
I'll give you an overview of my scenario:
I've got a main page with a TabStrip and a Callbackpanel. The TabStrip calls a callback to update the Callbackpanel. The Callbackpanel has a dynamically loaded control added to it. The dynamically added control then becomes that main "section" for that particular tab. The dynamically added control has Button controls that are designed to execute commands server-side when the Buttons are clicked, and the Callbackpanel does a Callback.
Now, from what I have tried I cannot add the dynamically added control as a trigger to the Callbackpanel, as when the page has a Callback, it cannot find the Trigger control, even when it is re-created at Init, so to get around this I set the Button's onclientclick property to execute the Callback function manually with the parameter being the Button's ID. The dynamically loaded control checks the value of the eo callback paramater and fires the method associated with the Button's ID.
So far everything is good, viewstate is maintained across the Callbacks.
However one of the controls in the dynamically loaded control is an ASP.NET FileUpload control. It seems that when the Callback is fired, the page does not upload the file. How do I set up the Callbackpanel to allow the FileUpload's data to be used after a Callback? I changed the form's enctype to form-data but that did not work.
I was also wondering if your AJAX Uploader could work inside a dynamically loaded control inside a Callbackpanel and solve this issue?
Your assistance would be most appreciated.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, Yes. You can use our AJAX Uploader. Our sample project uses CallbackPanel to load all samples, including AJAX Uploader samples. So it does work with CallbackPanel well. Here is one of the samples: http://demo.essentialobjects.com/Default.aspx?path=AJAXUploader\_i0 One of the main differences between AJAX Uploader and a regular ASP.NET FileUpload is AJAX Uploader is a two step process. When you click Browse, then Upload (optionaly, the Uploader can automatically start upload for you after you browse a file), The upload begins. Once the upload is done, you can post back, which can be a regular postback or an AJAX callback. Please feel free to let us know if you have any more questions. Thanks!
|
|
Rank: Member Groups: Member
Joined: 1/26/2009 Posts: 13
|
Hi there,
Thanks for your quick reply.
I was thinking it may be possible to use your AJAX Uploader, however that will mean it will sit INSIDE a dynamically loaded control INSIDE a CallbackPanel? Is that fine?
Another question: Is it possible to use dynamically loaded controls as triggers? And when exactly would you have to load/re-load these controls in order to keep the Callbackpanel happy? I've tried numerous methods without success - If I could just set the dynamically loaded control as a trigger then I won't have to worry about managing all the manual callback triggers inside the control, since all the control's child objects would also trigger the callback.
Thank you very much.
|
|
Rank: Member Groups: Member
Joined: 1/26/2009 Posts: 13
|
Hi there,
I see what you mean regarding your Demo project - I've implemented it the same way and it seems to be working fine.
If you could let me know about setting dynamically loaded controls as Triggers I'd appreciate it.
Also, is it possible to have a Callbackpanel within a Callbackpanel?
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Dynamic loading is fine as soon as you do it early enough (such as inside Page_Init).
It is possible to use dynamically loaded control as triggers. The key is that the trigger control and the CallbackPanel need to be inside the same NamingContainer. For example, if you have the following page structure:
PageA.aspx -- CallbackPanel1 -- UserControl1 ---- Button1 In this case Button1 can not be set as a trigger for CallbackPanel1 because CallbackPanel1’s NamingContainer is PageA.aspx, while Button1’s NamingContainer is UserControl1. It works this way because if the CallbackPanel were to allow Button1 inside a different NamingContainer (in this case UserControl1) and PageA.aspx also contained a “Button1” control, then the CallbackPanel1 won’t know which one to use.
The NamingContainer restriction is rarely an issue for static pages since the designer only shows you all the controls inside the same NamingContainer (usually the same page or the same user control). However it can quickly become an issue when you use code to dynamically load a user control.
The easiest way to work around this problem is to set the parent NamingContainer, in this case, UserControl1 as the trigger. This will enable all child controls of UserControl1 as trigger.
If enabling all child controls of UserControl1 as trigger is not appropriate, you can use two CallbackPanels. You would place one inside UserControl1 (say CallbackPanel1) and one outside UserControl1 (say CallbackPanelB) but setting their GroupName to the same value. You would then “Button1” as CallbackPanelA’s Trigger. Because both CallbackPanels have the same GroupName, triggering CallbackPanelA will update both CallbackPanels.
Hope this helps. Please feel free to let us know if you have any more questions.
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
ibraheem wrote:Also, is it possible to have a Callbackpanel within a Callbackpanel? Yes. It is possible to have one CallbackPanel inside another CallbackPanel. Thanks!
|
|
Rank: Member Groups: Member
Joined: 1/26/2009 Posts: 13
|
Thanks for your reply -
You said the CallbackPanel and the Trigger need to be inside the same NamingContainer.
In your case CallbackPanel1 and UserControl1 are not in the same NamingContainer? That means that no child control of a CallbackPanel can be used as a Trigger?
In my case I have:
Page.aspx - CallbackPanel1 -- DynamicallyLoadedControl1
But DynamicallyLoadedControl1 cannot be set as a Trigger for CallbackPanel1.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
I apologize for the confusion ---- our previous replay did not clearly indicate the parent/child relationship of the controls. The correct relationship should be: PageA.aspx -- CallbackPanel1 -- UserControl1 ----- Button1 Here CallbackPanel1 and Usercontrol1 are directly inside PageA.aspx, however Button1 is inside UserControl1. ibraheem wrote:In your case CallbackPanel1 and UserControl1 are not in the same NamingContainer? In the previous example, CallbackPanel1 and UserControl1 are in the same NamingContainer (which is the page); ibraheem wrote:That means that no child control of a CallbackPanel can be used as a Trigger? This is false. NamingContainer and parent are two different things. So: 1. You can use child control of a CallbackPanel as a Trigger because CallbackPanel is not a NamingContainer; 2. You can use child control of a UserControl as a trigger for a CallbackPanel that is inside the same UserControl; 3. You can not use child control of a UserControl as a Trigger for a CallbackPanel that is outside of the UserControl because UserControl is a NamingContainer; For example, you can set UserControl1 as CallbackPanel1's trigger in the previous example, but you can not set Button1 as CallbackPanel1's trigger because Button1 "belongs" to UserControl1 and not Page1. Various workaround for this are explained in our previous reply. ibraheem wrote:In my case I have:
Page.aspx - CallbackPanel1 -- DynamicallyLoadedControl1
But DynamicallyLoadedControl1 cannot be set as a Trigger for CallbackPanel1. This should definitely work. If it continues to give you problem, please post a test page that reproduces the problem, we will be happy to take a look and see what we can find. Please make sure the page runs independently. Thanks!
|
|
Rank: Member Groups: Member
Joined: 1/26/2009 Posts: 13
|
Thank you very much for the clarification. I'll look into this some more and update you.
Many thanks for the assistance.
|
|
Rank: Member Groups: Member
Joined: 1/26/2009 Posts: 13
|
Hi there,
I think I've found the problem. Here's what's happening:
Page loads, DynControl is loaded and added to CallbackPanel control collection. Next, DynControl's ID is added as a Trigger to CallbackPanel.
What I'm trying to do is, during a Callback, Clear() the CallbackPanel's Trigger collection so that whatever DynControl is to be loaded, the only Trigger in CallbackPanel's Trigger collection will be for the new DynControl.
I think that a Callback request cannot modify the Triggers collection of the CallbackPanel? The Error I'm getting is that the CallbackPanel is looking for the old Trigger ID which of course is no longer on the page. It seems the call to CallbackPanel.Triggers.Clear() is ignored if its called from within a Callback request.
Is the above correct? And if so, what's the workaround?
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
I think you've found the problem. :) The CallbackPanel will not update its own Trigger collection through Callback because the AJAX call would only update its child controls, not the CallbackPanel itself.
The easiest workaround is to always use the same ID. If that is not workable to you, there are several options:
1. Use OnClientClick like you mentioned in your original post. This way you basically takes over the trigger mechanism and replace it with your own;
2. Use a parent control to host your button control and always use the same ID for that parent control. You would then set that parent control, instead of the button as the trigger. The takes advantage of another CallbackPanel feature: If you set a parent control as a Trigger, all child controls are automatically triggers.
Note: In the current public build, the parent control must be a NamingContainer (the easiest way is for you to define a new class that inherits from Panel control and also implement INamingContainer, which is a marker interface that does not have any methods). We have an internal build that would remove this NamingContainer restriction, please let us know if you are interested in that build;
Hope this helps.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 1/26/2009 Posts: 13
|
Hi there,
Thank you for clarifying. I've stuck to a single ID for the loaded controls and that will solve the problem. Now I don't have to implement my own Callback mechanism!
The EO.Web library looks very powerful and the support is exceptional. Will definitely be using your software in our upcoming projects.
Thanks again.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Glad to hear that! Please feel free to let us know if you have any more questions!
|
|