Need value written during client-side OnRequestStart

2 posts, 0 answers
  1. eakins05
    eakins05 avatar
    12 posts
    Member since:
    Jun 2007

    Posted 14 Jan 2010 Link to this post

    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:

    <asp:ScriptManager runat="server"
    <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1"
            <telerik:AjaxSetting AjaxControlID="btn"
                    <telerik:AjaxUpdatedControl ControlID="hField" /> 
                    <telerik:AjaxUpdatedControl ControlID="textbox" /> 
                    <telerik:AjaxUpdatedControl ControlID="btn" /> 
                    <telerik:AjaxUpdatedControl ControlID="label" /> 
        <ClientEvents OnRequestStart="requestStart" /> 
    <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; 

    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)?


  2. Nikolay Rusev
    Nikolay Rusev avatar
    2289 posts

    Posted 18 Jan 2010 Link to this post

    Hello Jared,

    OnRequestStart client event of RadAjaxManager/RadAjaxPanel is listening for initializeRequest of PageRequestManager. When initializeRequest event happens all the data that need to be send on postback is already prepared and this is the reason for not seeing the value on server. Thus hidden field value must be changed before this event - in client button click might be the right place in the sample scenario.

    Sincerely yours,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top