dynamic call of a function

G

Guest

how can i call a function
where i recive its name from a query string and i want to call that function
(in asp it was with Eval function)
and how can i call it if i have parameters too?

thnaks in advance
peleg
 
F

Forum

It is not a good thing to mention your fully functions in the querystring.
It´s better to pass a string by the querystring and in the page_load event
get that string and do the right action then. Also you can put parameters in
the querystring and get them in the same event.
 
G

Guest

i agree with that 100% !
the problem is hat the client side was wrote long ago and know i cant change
it
so how can i call a function dynamiclly?
 
I

IfThenElse

string methodToCall = "TheFunctionOrMethodNameToCallDynamicall";
Return CType(Me.GetType().InvokeMember(methodToCall, BindingFlags.Instance
Or BindingFlags.Public Or _

BindingFlags.InvokeMethod, Nothing, Me, New Object()
{SomeParameterYouArePassing_Id, SecondParameterEtcAndThirdCommaDelimited}),
Byte())



In this case I am invoking, Dynamically, a function that returns a Byte()
Array.



Etc..
 
G

Guest

wow i thought its easy like in asp :)
do u have mabye a link to an example?
thanks alot
peleg
 
I

IfThenElse

This is an example.

string methodToCall = "TheFunctionOrMethodNameToCallDynamicall"; // put
the function name you want to call here.

Return CType(Me.GetType().InvokeMember(methodToCall, BindingFlags.Instance
Or BindingFlags.Public Or BindingFlags.InvokeMethod,
Nothing, Me, New Object()
{SomeParameterYouArePassing_Id,
SecondParameterEtcAndThirdCommaDelimited}), Byte())

This is where you pass the parameters if you have any.
{SomeParameterYouArePassing_Id, SecondParameterEtcAndThirdCommaDelimited}),

The function you are calling is withing the same class hence
Me.GetType().etc.....

read more about the flags for the method above....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,224
Latest member
BettieToom

Latest Threads

Top