v
Not logged inv
SearchAsk a QuestionReport an IssueMake a SuggestionMy Questions and Issues
Issue Details
Find By ID

ASPxCallbackPanel dynamic controls and Page_Load

Issue Details

Log in to Track Changes or Edit
Q203539
Question
Dave Haas
Yes
Processed
Answered
.NET (ASP.NET)
ASPxperience Suite
9.1.2
Windows XP
Microsoft Visual Studio 2008
4/30/2009 1:17:17 PM
-> Created by Dave Haas 4/23/2009 5:32:25 PM

Hi.

I've got a scenario that I'm having trouble figuring out how to do. Basic page, ASPxTreeList on the left, ASPxCallbackPanel on the right. When someone clicks a node in the treeview I dynamically load some controls (defined in an xml document for the moment) into the callbackPanel. Works fine.

Now, however, I need to iterate over those controls (preferably on the client side) and build a url with the controlName=controlValue combinations. Seems easy enough. There are however, some issues.

1) On the client side I'm having trouble pulling out the controls that got added (by name). Due to the container hierarchy i get names like 'panelReportParameters_callbackPanelParameters_ctl06_p_afeName' for a simple text box. It's quite a bit more complicated if I try to use a date chooser or something like that (bunch of 'DDD' stuff gets appended, things like that). Note that the controls that get added dynamically are actually defined in a user control. The callbackPanel loads the user control during the callback.

2) If I try to collect the names of the controls using a button and postback instead, they are not available as a collection of controls from the CallbackPanel.Controls method. I'm assuming that's because they get added during the callback and not during the page_load event.

So how would you solve this? Am I missing an easier way? Is there a way to load the user control into the callbackPanel during the page_load event of the callback? I can't seem to find a way to figure out how to get the parameter for the callback at that point and so I don't know which user control to load.

Suggestions?

Dave

<- Processed (Answered) by DevExpress Team 4/23/2009 11:08:44 PM

Hi Dave,

If you need to refer to our control from your client-side script the easiest solution would be to initialize their ClientInstanceName. So, for example, if the editor's ClientInstanceName property is set to the "txtBox" value, you can use code similar the following:

[JScript]

var value = txtBox.GetValue();

Will this functionality serve your needs?

NOTE: If you're using our controls in a WebUserControl and there are multiple instances of the UserControl on a page, please follow our recommendations from this report: GridView within different instances of a UserControl.

Thanks,
Serge

P.S. By the way, it seems you're using an older build of our components (according to the report's Version field). Please visit our version info page, to learn about the most recent versions of our products, and obtain instructions on how to update them.

<- Processed (Customer Closed) by Dave Haas 4/24/2009 3:24:35 PM

Hi.

I re-read my original post and I think I need to clarify. It's not that I'm having trouble getting the value for a control on the client side. The problem is best described by a detailed sequence of steps.

I'll also include the project so you can see what I'm trying to do.

1) There is a list of reports defined in an xml file. A report has the form <report name='blah' parameters='blah.ascx' />
2) The list of reports is loaded into a tree view
3) On the client side, a selection change in the treeview triggers a callbackpanel to load the ascx file for the report.
4) I don't know what's in the ascx file. All I know is that there are some controls that define the parameters for the report.
5) After the control is loaded on the client side I would like to be able to loop through the controls of the dynamically loaded ascx file, get their names and values and build a url so that I can call the actual report via this url. The server that runs the report is a completely different thing and not part of this. This system is solely to capture the parameters for the report and to build the url.

I've tried to loop through the control names (since I don't know the names) by relying on a naming convention. This is problematic since the DevExpress controls are composed of many parts and so knowing which control is real and which control is a sub-control is difficult.

What I'd like to be able to do is reference the controls via the callbackpanel.controls collection during a postback that is triggered by a button:

1) tree of controls loads
2) user clicks a treenode
3) the ascx for the treenode is loaded into the callbackpanel
4) user fills out controls
5) user presses 'go' button
6) during the postback for the 'go' button i collect the names and values for the callbackpanel.controls collection and build my url

The only flaw in the reasoning seems to be that the callbackpanel.controls collection is empty during the button postback, presumably since during that postback i'm not reloading the controls into the callback panel in the page_load event. The reason is, at that point, i don't know what they are. I supposed I could get the focused node for the tree, load the controls in the page_load event again and try to fill them from viewstate but I have questions:

1) Can this be done?
2) Does the viewstate get sent back for controls that are dynamically loaded into a callbackpanel during a postback (in this case the button)?
3) Is there an easier way to do this?

I appreciate the help :)

Cheers,

Dave

-> Reactivated by Dave Haas 4/24/2009 3:26:52 PM

Attachment: SCRTParameterPages.zip (28063 bytes)

Oops. Here's the project :)

Dave

<- Updated by DevExpress Team 4/28/2009 2:11:20 AM

Thank you for the project, Dave. We're examining it and will respond soon. Please bear with us.

Regards,
Serge

<- Processed (Answered) by DevExpress Team 4/30/2009 1:17:17 PM

Attachment: dxSample_Q203539.zip (31299 bytes)

Hi Dave:

The cause of the problem with the postback (when you click the "Run report" button and cannot find any control in the callback panel) is that you add these controls on the callback of the ASPxCallbackPanel only. Thus, when you submit a form, the control's collection is empty. To solve this issue, you should add controls on every request (every Page_Load)
I've modified your sample according to this solution and attached it. If this solution doesn't meet your requirements, please let me know.

Thanks
Kate.

Log in to Track Changes or Edit

Peer-to-Peer Discussion in DevExpress Forums

No discussion on this article has been started yet.

Please login to start discussion.

v
v
Search
Searching Tips