Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
345
How to force page postback on add new row with ajax enabled
posted

 I have ajax enabled on my grid. I'd like to force a full page postback after a new row is added. Is there a way to do this?

Parents
  • 19308
    posted

    There are a couple of ways I can think of off the top of my head.  The first would be to use the BeforeXMLHTTPRequest client-side event that the WebGrid fires before any AJAX interaction - http://help.infragistics.com/NetAdvantage/NET/2008.3/CLR3.5 

    When you handle this event, you can cancel the request if the action was a new row added, and call __doPostBack manually instead.

    The second option would be to handle this from the server-side.  When you handle the RowAdded server-side event, emit a scriptblock that calls __doPostBack on the client-side.  This would force the client to first complete the add asynchronously, and then perform a full postback. 

    Hope this helps,

    -Tony

Reply
  • 345
    posted in reply to [Infragistics] Tony Lombardo

    Ok, tried #1. Strange thing is that BeforeXMLHTTPRequest only seems to fire for Updates but not when a new row is inserted. The following function would only give me hi7 (update) and no hi5(add new row):

    function BeforeXmlHttpRequest(gridName, type) { alert('hi' + type); }

    Also tried dopostback with ClientSideEvents-AfterRowInsertHandler. It would indeed postback when I clicked on the Add Row button but won't give me a new row after the postback.

    Tony Lombardo"]

    The second option would be to handle this from the server-side.  When you handle the RowAdded server-side event, emit a scriptblock that calls __doPostBack on the client-side.  This would force the client to first complete the add asynchronously, and then perform a full postback. 

     

    Sorry don't know where/how exactly to handle the RowAdded server-side event? Is there any sample code. Right now my aspx.vb page just has an empty sub:

        Protected Sub UltraWebGrid1_AddRow(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.RowEventArgs) Handles UltraWebGrid1.AddRow

        End Sub

     Any code I put in there doesn't do anything.

    Thanks for trying to help out Tony!

    Regards,
    Ali

    P.S. Is there a way to initiate rowupdate from the ClientSideEvents-AfterRowInsertHandler? Then I could immediately do a postback after update.

Children