e I am a little struggling with the following conditions. I have implemented ICallBackEventHandler in my web pages, everything runs smooth except that returning value from the back-end is not readable for the javascript function. In the console the post shows up the correct returning value, but the argument of the function is always empty.
public partial class Intro : System.Web.UI.Page, System.Web.UI.ICallbackEventHandler
{
private string eventType = String.Empty;
protected void Page_Load(object sender, EventArgs e)
{
//ICallBack event handler
ClientScriptManager cm = Page.ClientScript;
string cbReference = cm.GetCallbackEventReference(this, "arg", "HandleResult", "");
string cbScript = "function RaiseEvent(arg){" + cbReference + ";}";
cm.RegisterClientScriptBlock(this.GetType(), "RaiseEvent", cbScript, true);
//End of ICallBack event handler
}
}
public void RaiseCallbackEvent(string eventArgument)
{
eventType = eventArgument;
}
public string GetCallbackResult()
{
return "simple";
}
And then in the front-end I have the following scenario: I trigger the event on button click using this : RaiseEvent("start")
and I am handling the result with the this function :
function HandleResult(arg) {
alert(arg); // HERE THE ARGUMENT IS ALWAYS NULL OR EMPTY !!!
}
Please help me find out why this is not running properly and why I cannot access the value of the returned argument. Thank you in advance.
This is usually caused by not using the Page.IsPostBack