I created an app stand alone and it works with my callback. I am trying to integrate it into a larger app and am having some issues.
My stand-alone app callback code:
public partial class Default : System.Web.UI.Page, System.Web.UI.ICallbackEventHandler
{
protected void Page_Load(object sender, EventArgs e)
{
//unimportant specific code
//Get the Page's ClientScript and assign it to a ClientScriptManger
ClientScriptManager cm = Page.ClientScript;
//Generate the callback reference
string cbReference = cm.GetCallbackEventReference(this, "arg", "HandleResult", "");
//Build the callback script block
string cbScript = "function CallServer(arg, context){" + cbReference + ";}";
//Register the block
cm.RegisterClientScriptBlock(this.GetType(), "CallServer", cbScript, true);
}
public void RaiseCallbackEvent(string eventArgument)
{
//unimportant specific code
//This method will be called by the Client; Do your business logic here
//The parameter "eventArgument" is actually the paramenter "arg" of CallServer(arg, context)
GetCallbackResult(); //trigger callback
}
public string GetCallbackResult()
{
//unimportant specific code
return callbackMessage;
}
//more specific unimportant stuff
}
Why can I not just add the class to my larger app like this:
public class My_App_ItemViewer : abstractItemViewer, System.Web.UI.Page, System.Web.UI.ICallbackEventHandler
In visual studio, I get an error that says 'page' interface name expected.
In the callback code itself, I get an error where it references to ClientScript saying 'cannot access static property 'clientSript' in nonStatic context'.
I do not really understand these terms... I do not have a CS degree or anything, so if anyone could explain this, that would be great (perhaps even the greatest), thanks!
C# does not support multiple inheritance, so you cannot do the following line:
Just to clarify, the way you have written the above, the C# compiler thinks that abstractItemViewer is a class that you are trying to inherit from. The compiler then sees the "System.Web.UI.Page" part and is looking for an interface named that, it does not find it, because System.Web.UI.Page is a class and not an interface; thus error.
You can, however, implement multiple interfaces, so you could do the following: