Solved

UserControl Argument Array

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Web site error 3 36
Creating a route in asp.net webforms 2 25
Search an image for an image 3 27
What Does This C# Code Block Do? 5 24
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 …
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 video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

10 Experts available now in Live!

Get 1:1 Help Now