Solved

UserControl Argument Array

Posted on 2014-04-01
2
299 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

911 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

20 Experts available now in Live!

Get 1:1 Help Now