Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Passing multiple values using a Pagefunction

Posted on 2008-10-25
8
Medium Priority
?
395 Views
Last Modified: 2013-12-17
Hi Guys,

Does anyone know how to pass MULTIPLE values using a Pagefunction? There are lots of examples for returning a single value, but I need to return multiple values.

Any help would be greatly appreciated.

Thanks,

Stephane Touya
0
Comment
Question by:MrTouya
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 16

Expert Comment

by:ororiole
ID: 22806225
You can use a collection. Here I have used a collection of string, but of course it can be whatever you want.
void doneButton_Click(object sender, RoutedEventArgs e)
{
    // Complete the page function and return data of type List<>
List<string> list = new List<string>()
{
"first",
"second",
"third"
};
    OnReturn(new ReturnEventArgs<List<string>>(list);
}
 
//and in the calling page you handle the return event
List<string> = e.Result

0
 

Author Comment

by:MrTouya
ID: 22807004
Good Idea! I will try it and let you know.
0
 

Author Comment

by:MrTouya
ID: 22807086
HI ororiole,

So Close. I realized that the values I am returning are of two different types. One is an interface type to a third party Engine and the other is enum to the engine type.  I am still stuck.

Stephane
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 16

Accepted Solution

by:
ororiole earned 2000 total points
ID: 22808116
Then lets use a non generic collection that contains objects. You will need to test for the type when you remove the object. I didnt compile this, but you get the idea.

void doneButton_Click(object sender, RoutedEventArgs e)
{
   // Complete the page function and return data of type ArrayList
   MyClass myClass = new MyClass();
   MyEnum myEnum = MyEnum.one;

  ArrayList al = new ArrayList();
  al.Add(myClass);
  al.Add(myEnum);

  OnReturn(new ReturnEventArgs<ArrayList>(al);
}

//now in the calling page it looks something like this

ArrayList myList = e.Result;
object o = myList.Remove();
if ( o is MyClass )
{
  MyClass thisclass = (MyClass) o;
  //do something here
}
else
if ( o is MyEnum)
{
  MyEnum thisEnum = (MyEnum) o;
  //something else
}
else
{
  //what is this? :)
}




0
 

Author Closing Comment

by:MrTouya
ID: 31510048
Thanks. That did it :-)
0
 

Author Comment

by:MrTouya
ID: 22809175
Oops. one more questions. What namespace should I be using?

clr-namespace:System.Collections;assembly=mscorlib?
 
0
 

Author Comment

by:MrTouya
ID: 22809387
Hi ororile,
 I am close. Now I am getting this error right after the OnReturn event:
 Exception of type 'System.ExecutionEngineException' was thrown.
This is my code
ArrayList EngineValuesList = new ArrayList();
EngineValuesList.Add(_MyEngine);
EngineValuesList.Add(_selectedEngineType);
EngineValuesList.TrimToSize();
OnReturn(new ReturnEventArgs<ArrayList>(EngineValuesList));  
 
I am going to open up another question so you can get the credit.
 
Stephane
0
 
LVL 16

Expert Comment

by:ororiole
ID: 22810580
You found System.Collections I presume? sorry, I had a lot of weekend things to get done. :)
ExecutionEngineException? Hmm, have to think about that one a bit.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

670 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