Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsClientAPIClientAPIDefinining a callback functionDefinining a callback function
Previous
 
Next
New Post
1/10/2006 5:58 PM
 
jamador wrote

Ok, sorry about my bollean english confusion, let me reformulate the question.

To call the server side code we add an attribute to the "onclick" event of a button or control, this is all working, but what i was looking for was just a way to call the server side code inside my javascript function, something like :

function Some_JavaScript_Function() {

var GetValue = Server_Side_Code(); 

} 

Regards,

João Amador

One thing you should note is that there will be no way for you to get the result right away, meaning var GetValue = Server_Side_Code();   Instead you will have to specify a function to handle the return value asyncronously.  Yes, you can do synchronous calls, but it is not recommended, since it makes the browser appear to be locked up. (javascript is not multi-threaded).


 
New Post
1/10/2006 6:04 PM
 
Hi there,

Sorry for saying i didn't get it what you are trying to say,
but i'm sure this is my lack of experience with this.

The way i've managed to get some sort of my inteded functionality was

- In Javascript i define a global var

var V_CALL_SERVER;

- Then a function to call the "doCallBack". setting the second parameter to the name of the function to diferentiate on the server side

function CALL_SERVER() {
dnn.xmlhttp.doCallBack('__DNNCAPISCPAGEID','CALL_SERVER',CALL_SERVER_RESULT,this,errorFunc);
}



- Then the function to receive the response and set the global var(V_CALL_SERVER) with the result

function CALL_SERVER_RESULT(result, ctx) {
V_CALL_SERVER=result;
}



-Ok now i can call anywhere in my code the function and get the result
in the global var

CALL_SERVER();
var result_from_call = V_CALL_SERVER;


------------------------------

- To diferentiate on the server side which function was called i'm using the dnn.xmlhttp.doCallBack second parameter
in this exemple "CALL_SERVER" also :

Public Function RaiseClientAPICallbackEvent(ByVal eventArgument As String)....
if eventArgument="CALL_SERVER" then
CALL_SERVER()
....
end function



Awkward ?? you bet, but it was the only way i've made it work, please show me a better way.
Also the second parameter (strArgument) was the way to pass arguments to the server side code, so
i'm still left with a problem, how to send data to the server.

Regards,
Joao Amador
 
New Post
1/11/2006 9:21 AM
 

jamador wrote
Hi there,

Sorry for saying i didn't get it what you are trying to say,
but i'm sure this is my lack of experience with this.

The way i've managed to get some sort of my inteded functionality was

- In Javascript i define a global var

var V_CALL_SERVER;

- Then a function to call the "doCallBack". setting the second parameter to the name of the function to diferentiate on the server side

function CALL_SERVER() {
dnn.xmlhttp.doCallBack('__DNNCAPISCPAGEID','CALL_SERVER',CALL_SERVER_RESULT,this,errorFunc);
}



- Then the function to receive the response and set the global var(V_CALL_SERVER) with the result

function CALL_SERVER_RESULT(result, ctx) {
V_CALL_SERVER=result;
}



-Ok now i can call anywhere in my code the function and get the result
in the global var

CALL_SERVER();
var result_from_call = V_CALL_SERVER;


------------------------------

- To diferentiate on the server side which function was called i'm using the dnn.xmlhttp.doCallBack second parameter
in this exemple "CALL_SERVER" also :

Public Function RaiseClientAPICallbackEvent(ByVal eventArgument As String)....
if eventArgument="CALL_SERVER" then
CALL_SERVER()
....
end function



Awkward ?? you bet, but it was the only way i've made it work, please show me a better way.
Also the second parameter (strArgument) was the way to pass arguments to the server side code, so
i'm still left with a problem, how to send data to the server.

Regards,
Joao Amador

First, let me start out by saying that I would be worried about using global variables in this manner.  The reason for my worry is that you are doing async calls, and if 2 calls are made you have no way of distinguishing which result goes with which call, I suppose this could be a use of the context variable.  The code you gave

CALL_SERVER();
var result_from_call = V_CALL_SERVER;

may just be an over simplification, but as it is written will not work, for when you invoke CALL_SERVER, then immediately attempt to get the results will not work async.  If you are attempting synchronous calls, then it would work, but like I mentioned earlier is not recommended  (especially if you need to support many browsers, for my IFrame implementation of the callback (used for Safari and Opera) does not support sync calls.)

To answer your question about passing in different arguments.

function CALL_SERVER() {
dnn.xmlhttp.doCallBack('__DNNCAPISCPAGEID','CALL_SERVER',CALL_SERVER_RESULT,this,errorFunc);
}

You have a hardcoded string in your sample.  I suggest having this parameter be another funciton call or better yet have it reference a passed in parameter

function CALL_SERVER(theArgument) {
dnn.xmlhttp.doCallBack('__DNNCAPISCPAGEID',theArgument,CALL_SERVER_RESULT,this,errorFunc);
}


 
New Post
1/11/2006 9:46 AM
 

Hi there,

Thanks for bearing with me on this questions.

- If i use the argument as you correctly said to pass the parameters, how do i know on the server side wich code to execute, in the case that i wan't to implement several diferent call's .since the callback always calls the same server side function, probably the "context" ?, but server side function only receives one argument ?

- Ok, synchronous maybe an hazard, but if i wanted to do one of this calls , how do i do it.

Regards,

Joao Amador

 
New Post
1/11/2006 5:24 PM
 

It is completely up to you as to how many unique server side calls you decide to implement.  It was your idea to come up with this global call in the first place, so I'd assumed that you already worked out your answer to which one is making the call...  yes, the call only passes one argument, but it is a string, which means you can pass as many values as you'd like, just delimit them, or use xml.

I suggest reviewing the document I provided to answer some of your other questions (DotNetNuke ClientAPI ClientCallbacks v1.0.1 ).

 


 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsClientAPIClientAPIDefinining a callback functionDefinining a callback function


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out