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

RadAjaxManager doen't get call server side ajax handler every time

1 Answer 51 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Maulin
Top achievements
Rank 1
Maulin asked on 28 Jul 2010, 08:07 PM
Hi,

I am using telerik RadAjaxManager in my application and trying to build functionality as per demo i found below:

http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=grid

What i could see when first time i Open window from javascript after i close my window, my ajax server side event first get call and bind gird and then during databind radgrid_item created event get called, but immediately next time when i perform the same action to add 2nd record to my gird, after i close popup window, instead of calling server side ajax handler, it's calling radgrid_itemCreated first and then ajax handler. so throwing an exception while executing
editLink.Attributes["onclick"] = String.Format("return ShowEditPopUps('{0}','Speaker');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["SpeakerID"]); line of code

actually it should first call Ajax request server side event first and then RadGrid_ItemCreated.

any help would be appreciated.

below is my client side  java script code

function ShowProductPopUps(strPopup)
            {
                var strId = "";
                var height = 0;
                height = 150;
                                
                var strRet = ShowPopUp(strPopup, "CityEvent&id=" + strId , height, 600);
                
                 if ((strRet != undefined) && (strRet != ""))
                {
                   alert(strRet);
                   $find("<%=RAM.ClientID%>").ajaxRequest(strPopup + "-" + strRet );
                }
                
                return false;
            }

Rad Ajax Manager:
<telerik:RadAjaxManager ID="RAM" runat="server" OnAjaxRequest="RAM_AjaxRequest" >
         <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RAM">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="grdSpeaker"/>
                        <telerik:AjaxUpdatedControl ControlID="btnSpeaker"/>
                    </UpdatedControls>
                 </telerik:AjaxSetting>
                 <telerik:AjaxSetting AjaxControlID="grdSpeaker">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="grdSpeaker" />
                        </UpdatedControls>
                  </telerik:AjaxSetting>
                 
         </AjaxSettings>        
    </telerik:RadAjaxManager>

and my server side ajaxHandler and radgrid_itemcreated event handler

 protected void RAM_AjaxRequest(object sender, AjaxRequestEventArgs e)
        {
            //string abc = string.Empty;
            string gridType = e.Argument.Split('-')[0];
            switch (gridType)
            {
                case "Speaker":
                                 EVMSessionManager oSession = new EVMSessionManager();
                                 this.grdSpeaker.DataSource = oSession.SpeakerData;
                                 this.grdSpeaker.DataBind();
                                 break;
                case "SignOff":
                                 break;
            }
        }


RadGrid Item_Created event handler
protected void grdSpeaker_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                HyperLink editLink = (HyperLink)e.Item.FindControl("editLink");
                editLink.Attributes["href"] = "#";
                editLink.Attributes["onclick"] = String.Format("return ShowEditPopUps('{0}','Speaker');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["SpeakerID"]);
            }
        }

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 02 Aug 2010, 02:30 PM
Hello Maulin,

Actually the sequence of events you are experiencing on post-back from the pop-up window is just expected as RadGrid firsts loads its ViewState and recreates its structure from it, then come the server controls event handlers and if the grid is rebound, it will again recreate its structure from the new data and ItemCreated event called a second time but with a relevance to the new data retrieved. More information you can find at the following help topic:
http://www.telerik.com/help/aspnet-ajax/grdeventsequence.html

If the problems persista, could you specify what error you are getting?

Regards,
Tsvetoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Maulin
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or