Solved

Passing multiple values using a Pagefunction

Posted on 2008-10-25
8
381 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
  • 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
 
LVL 16

Accepted Solution

by:
ororiole earned 500 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 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