Solved

UserControl Argument Array

Posted on 2014-04-01
2
295 Views
Last Modified: 2014-04-02
Hi all,

I have an usercontrol class whereby I bubble click methods back to the parent ASPX page to dynamically load other usercontrols (much like a wizard).

As the moment I simply call OnBubbleClick(nextUserControlName); which is caught back on the aspx and loads the next control to the updatepanel

Now a couple of my usercontrols now require different variables to be set. For example I have a Page.ascx where I want to pass across a ID field to pull the relevant text from a database and also and Error.ascx where I will pass an error message and error dump to be displayed.

I have been thinking of the best way about this and thought about changing the OnBubbleClick(nextUserControlName) to be;

OnBubbleClick(string nextUserControlToLoad, string[,] args)

Open in new window


so in this situation i would just pass string['ID', '2'] and in the page load for the page.ascx test for the ID field being present

in the error case string['message', 'error message',  'dump', 'error dump']

does this sound the best way of going about things?

Also, in this case how would I 'search' the array on the page load? and would this have any impact on performance from say, creating types and test for these?
0
Comment
Question by:flynny
2 Comments
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 500 total points
ID: 39970538
I would use a dictionary so it is easier to identify/get the keys you are using:
OnBubbleClick(string nextUserControlToLoad, Dictionary<string, string> args)

Open in new window


Note: Another option (if you found yourself repeating the same name value constructs) is to create a class with Id, Message and Dump as public properties.
0
 

Author Closing Comment

by:flynny
ID: 39971533
thanks I was thinking this may be the bast way to go about but just wanted a second opnion
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now