Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Passing multiple values using a Pagefunction

Posted on 2008-10-25
8
Medium Priority
?
400 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

824 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