GetCallbackEventReference doesn't do anything

nefarious1

New Member
I have an ASP.Net application that must show a label when i changed value from a combo:
  • in cs file:\[code\] public partial class WebFormAJAXControls : System.Web.UI.Page,System.Web.UI.ICallbackEventHandler {string _callbackArg;public void RaiseCallbackEvent(string eventArgument){ _callbackArg = eventArgument;}public string GetCallbackResult(){ return _callbackArg;}protected void Page_Load(object sender, EventArgs e){ //register the name of the client side function that will be called by the server string callbackRef = Page.ClientScript.GetCallbackEventReference(this, "args", "ClientCallbackFunction",""); //define a function used by client to call server string callbackScript = " function MyServerCall(args){alert ('1'); " + callbackRef + " ; }"; //register the client function to the page Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyServerCall", callbackScript, true);} }\[/code\]
  • in aspx file:\[code\] <head runat="server"> <title></title> <script type="text/javascript"> function ClientCallbackFunction(args) { alert(args); LabelMessage.innerText = args; } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:DropDownList ID="DropDownListChoice" runat="server" OnChanged="MyServerCall(DropDownListChoice.value)"> <asp:ListItem>Choise 1</asp:ListItem> <asp:ListItem>Choise 2</asp:ListItem> <asp:ListItem>Choise 3</asp:ListItem> </asp:DropDownList> <br /><br /> <asp:Label ID="labelMessage" runat="server"></asp:Label> </div> </form> </body>\[/code\]
When I change selection in the combobox the program doesn't do anithing.Can somebody tell me what's the problem?
 
Back
Top