Solved

Passing multiple values using a Pagefunction

Posted on 2008-10-25
8
383 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
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.

 
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
 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Export import database 4 51
Where did System.Data.Objects go? 2 23
VB.NET 2008 Publish Error 2 25
Call Controller Action Method from ASPX 2 13
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…
A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

785 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