ICallbackEventHandler synchronous bis ?

K

KaNos

Sorry always the same question.

I press a HTML button :
<input name="butGet" type="button" value="Get()" style="width: 147px"
id="butGet" onclick="butGet_onclick()" />

This event call a javascipt function butGet_onclick():
function ToInitialize()
{
var result = Get("");
if ( result != "true" )
{
alert ("Not True");
}
}

In this function, I wait the result of another Get("") :
var _strjReturn = "";
function Get(parameter)
{
strParameters = "Get" + "|" + parameter + "|";
CallServer(strParameters,"");
return _strjReturn;
}

The Callserver is created in the event page_load
protected void Page_Load(object sender, EventArgs e)
{
ClientScriptManager clientscriptMain = Page.ClientScript;

string strClientScript =
clientscriptMain.GetCallbackEventReference(this, "args",
"ReceiveServerData", "", false);
string strCallBackFunction = "function CallServer(args,context){" +
strClientScript + "}";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
"CallServer", strCallBackFunction, true);
}

With the client function :
function ReceiveServerData(args, context)
{
_strjReturn = args;
}

You understand that I use an inherit of ICallbackEventHandler with :
private _strReturn = "";
public string GetCallbackResult()
{
return _strReturn;
}

public void RaiseCallbackEvent(string eventArgument)
{
string[] arrArgument = eventArgument.Split('|');
if (arrArgument.Length != 0)
{
switch(arrArgument[0])
{
case "Get":
_strReturn = "true"
break;
default:
_strReturn = "Error"
break;
}
}
}

But, and is my problem, function Get(parameter) always send an empty string
and I show all the time the message "Not True". How can I capture the value
"true" and return this in the function Get(parameter) ? In google, I found
nothing.
Thanks for response ...
 

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

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top