This is a migrated thread and some comments may be shown as answers.

Force Synchronous PostBack From Within Grid

3 Answers 180 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 20 Apr 2012, 08:27 PM

I get 5 steps forward and then hit a brick wall with the RADGrid.

I have a page with a MultiView, encapsulating two views. View1 displays View2 when a particular LinkButton is pressed. On View2, I have a RADGrid. Within it I am dynamically creating a ButtonColumn of LinkButtons. The issue is that when a LinkButton is selected from one of the rows, I need the MultiView to change back to View1. Problem is, because the LinkButton is inside the RADGrid, it execute as an Asynchronous PostBack, and even though my code changes the CurrentView of the MultiView, the change doesn't get applied. I was thinking that what I needed was to designate all the LinkButtons inside that particular column as requiring a full Synchronous PostBack when clicked.

I tried the following, but it didn't work:
  Note: ButtonColumnsRequiringFullPostBack is a simple String Array holding the Unique Column Names of any columns with LinkButtons that I want to make as Synchronous Postback.

Private Sub gridMain_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles gridMain.ItemCreated
     If (e.Item.GetType() Is GetType(GridDataItem)) Then
          '***************************************
          ' Initialize Variables
          '***************************************
          Dim objDataItem As Telerik.Web.UI.GridDataItem = e.Item
 
          For Each strUniqueColumn As String In Me.ButtonColumnsRequiringFullPostBack
               With Telerik.Web.UI.RadScriptManager.GetCurrent(Me.Page)
                    .RegisterPostBackControl(objDataItem(strUniqueColumn).Controls(0))
               End With
          Next
     End If
End Sub

Now I don't get any error with this code...but it doesn't work either. I click the LinkButton inside the RADGrid, and it still executes Asynchronously...leaving the user on the same View2 page.

P.S. I am looking for a Server-Side solution, not a Client-Side one. Also I want to avoid wrapping the entire page in an UpdatePanel if avoidable. I think doing so may end up breaking a lot of the other functionality and I rather not spend days fixing the entire page to work AJAX style.

Any suggestions?



3 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 25 Apr 2012, 01:22 PM
Hi,

 You can try one of the approaches described in this help topic:
http://www.telerik.com/help/aspnet-ajax/ajax-exclude.html 

The server side approach is recommended to be applied in the Page_Load event. You can also use this on the client in the OnRequestStart event which provides much more flexibility.

All the best,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Ben
Top achievements
Rank 1
answered on 25 Apr 2012, 01:28 PM
Marin,

Thank you for the response. I did already come across that page you suggested, which is what I used as a template for my own code. Unfortunatly since this is a dynamically created column, I cannot place this particular code on the "PageLoad" event, because at that point in time, the column does not yet exist.

Unfortunatly I needed to get this resolved, it was holding up application development. So I was forced to update my entire page to use AJAX instead and then I dealt with all the consequences of doing so.

Again, thank you for the reply...but this method doesn't work for my situation.

-Ben
0
Marin
Telerik team
answered on 25 Apr 2012, 02:48 PM
Hi,

 It is recommended to add dynamically generated columns for the grid in Page_Init or Page_Load event, can you specify in which event you add them? Also this approach may not be suitable for dynamically generated buttons if they have different client IDs and are recreated on postback.
Another thing that I can suggest is to try to force the MultiView to be updated by asynchronous request from RadGrid. You can do this by adding the appropriate ajaxSetting in the RadAjaxManager. Here is a sample code:

<telerik:RadAjaxManager runat="server" ID="RadAjaxManager1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="MultiView1" />
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

This should make ajax request within the grid and from the grid to the MultiView, no other functionality of the page should be affected.

Regards,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Ben
Top achievements
Rank 1
Answers by
Marin
Telerik team
Ben
Top achievements
Rank 1
Share this question
or