I have a page that is handled entirely by AJAX, and there's an action that I need to perform on the client everytime before hitting the server. The RadAjaxManager's client-side OnRequestStart event seemed like the perfect place to do this, but what I'm doing is writing to a hidden field and trying to read that hidden field back on the server. When I take this approach, my value doesn't seem to be available server side. I put together a quick example that shows this:
And in the codebehind:
As this code stands, hField.Value is empty. If I comment out the contents of requestStart and uncomment btn_ClientClick, I get the results I expect. Is there something I'm missing, or am I using OnRequestStart in a way that wasn't intended. Is there another place I can put this (besides calling it from every client event that would cause a postback)?
Thanks,
Jared
| <asp:ScriptManager runat="server"> |
| </asp:ScriptManager> |
| <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1"> |
| <AjaxSettings> |
| <telerik:AjaxSetting AjaxControlID="btn"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="hField" /> |
| <telerik:AjaxUpdatedControl ControlID="textbox" /> |
| <telerik:AjaxUpdatedControl ControlID="btn" /> |
| <telerik:AjaxUpdatedControl ControlID="label" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| </AjaxSettings> |
| <ClientEvents OnRequestStart="requestStart" /> |
| </telerik:RadAjaxManager> |
| <asp:HiddenField ID="hField" runat="server" /> |
| <asp:TextBox ID="textbox" runat="server" /> |
| <asp:Button ID="btn" runat="server" OnClick="btn_Cick" OnClientClick="btn_ClientClick()" /><br /> |
| <asp:Label ID="label" runat="server" /> |
| <script type="text/javascript"> |
| function requestStart(sender, args) { |
| $get('hField').value = $get('textbox').value; |
| } |
| function btn_ClientClick() { |
| //$get('hField').value = $get('textbox').value; |
| } |
| </script> |
And in the codebehind:
| protected void btn_Cick(object sender, EventArgs e) |
| { |
| label.Text = hField.Value; |
| } |
As this code stands, hField.Value is empty. If I comment out the contents of requestStart and uncomment btn_ClientClick, I get the results I expect. Is there something I'm missing, or am I using OnRequestStart in a way that wasn't intended. Is there another place I can put this (besides calling it from every client event that would cause a postback)?
Thanks,
Jared