Hi,
I know I have the bad habit to put myself in complicated situations...., but it is not my fault, blame my customers ;-)
The Situation is as follows:
I have a Content Page which has as Master Page. Inside the content Page I load several User Controls. From one of the User Controls, which contains a RadGrid, I open a PopUp to edit the detail of the Grid. The PopUp contains a Button to save the detail and after saving I call a javascript function inside the Content Page (...actually inside the User Control) that triggers a AjaxCall to Rebind the Grid.
Everything works fine....only the first Time !!!
After that the debugger of Firefox tells me that the RadAjax Manager does not exists. I have to reload the Content Page (not even the User Control) to have the Rebind working again.
I'm pasting here some code.
The Master Page has nothing special inside it besides a
Beside that only HTML and CSS.
The Content Page:
...and the code to load the controls.
The User Control.
The Rebind javascript is to Rebind the RadGrid. The code behind just says:
The PopUp that is opened by the User Control:
..and the code behind to Update and trigger the Rebind.
So, to make a long story short, First Rebind ....works great...and then non more Rebind till Content Page full reload.
Any ideas ?
Thanks much as always.
Lorenzo
I know I have the bad habit to put myself in complicated situations...., but it is not my fault, blame my customers ;-)
The Situation is as follows:
I have a Content Page which has as Master Page. Inside the content Page I load several User Controls. From one of the User Controls, which contains a RadGrid, I open a PopUp to edit the detail of the Grid. The PopUp contains a Button to save the detail and after saving I call a javascript function inside the Content Page (...actually inside the User Control) that triggers a AjaxCall to Rebind the Grid.
Everything works fine....only the first Time !!!
After that the debugger of Firefox tells me that the RadAjax Manager does not exists. I have to reload the Content Page (not even the User Control) to have the Rebind working again.
I'm pasting here some code.
The Master Page has nothing special inside it besides a
<asp:ScriptManager runat="server" ID="ScriptManager"></asp:ScriptManager>The Content Page:
<%@ Page Title="" Language="VB" MasterPageFile="~/App_Master/SystemSetup/SystemSetup_base.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="SystemSetup_Default" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder_Top" Runat="Server"> <telerik:RadToolBar ID="RadToolBar1" runat="server" Width="100%" Height="26px"> <Items> <telerik:RadToolBarButton ImageUrl="Resources/Images/ico_Add_16.png"></telerik:RadToolBarButton> <telerik:RadToolBarButton Text="TEXT"></telerik:RadToolBarButton> </Items> </telerik:RadToolBar></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder_Left" Runat="Server"> <asp:button runat="server" ID="B_Eng" Text="ENG" Visible="false" /> <asp:button runat="server" ID="B_Ita" Text="ITA" Visible="false" /> <telerik:RadPanelBar ID="RadPanelBar" Runat="server" Width="100%" AllowCollapseAllItems="True" PersistStateInCookie="True"> <Items> <telerik:RadPanelItem runat="server" Text='<%$ Resources:Menu_Item_1 %>' PostBack="false" Expanded="true" > <Items> <telerik:RadPanelItem runat="server" Value="~/SystemSetup/Admin/Setup/CompanyList.ascx" Text='<%$ Resources:Menu_Item_1_1 %>' ImageUrl="~/SystemSetup/Resources/Images/ico_Company_16.png" Selected="true"></telerik:RadPanelItem> <telerik:RadPanelItem runat="server" Value="~/SystemSetup/Admin/Setup/OperatorList.ascx" Text='<%$ Resources:Menu_Item_1_2 %>' ImageUrl="~/SystemSetup/Resources/Images/ico_Users_16.png"></telerik:RadPanelItem> <telerik:RadPanelItem runat="server" Value="~/SystemSetup/Admin/Setup/RoleList.ascx" Text='<%$ Resources:Menu_Item_1_3 %>' ImageUrl="~/SystemSetup/Resources/Images/ico_Role_16.png"></telerik:RadPanelItem> </Items> </telerik:RadPanelItem> </Items> </telerik:RadPanelBar></asp:Content><asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder_Right" Runat="Server"> <asp:Panel runat="server" ID="P_Body" Width="100%" Height="100%"></asp:Panel></asp:Content>...and the code to load the controls.
Partial Class SystemSetup_Default Inherits System.Web.UI.Page Private Const CurrentControlKey As String = "CurrentControlKey" Private Property CurrentControl() As String Get Return IIf(ViewState(CurrentControlKey) = Nothing, "", ViewState(CurrentControlKey).ToString) End Get Set(ByVal value As String) ViewState(CurrentControlKey) = value End Set End Property Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ' Controlla la versioen del Browser e caccai via se IE inferiore a 8 If Request.Browser.Browser = "IE" AndAlso IsNumeric(Request.Browser.MajorVersion) AndAlso CInt(Request.Browser.MajorVersion) < 8 Then Dim Script As String = "alert('Plane è supportato solo da IE8 o versioni successive, Firefox e Chrome');" Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "Alert", Script, True) End If If Not IsPostBack Then CurrentControl = RadPanelBar.SelectedItem.Value End If Dim isNewControl As Boolean = Not CurrentControl.Equals(RadPanelBar.SelectedItem.Value) If isNewControl Then CurrentControl = RadPanelBar.SelectedItem.Value Else LoadUserControl(P_Body, CurrentControl, Not IsPostBack) End If End Sub Private Function LoadUserControl(ByVal parentControl As Control, ByVal newControlPath As String, Optional ByVal isFirstLoad As Boolean = False) As Control Dim control As Control = Page.LoadControl(newControlPath) control.ID = newControlPath.ToString.Replace("/", "_").Replace("~", "_").Replace(".", "_") 'AddHandler TryCast(control, IASControl).GenericEvent, AddressOf Me.HandleGenericEvent If isFirstLoad Then control.EnableViewState = False End If parentControl.Controls.Clear() parentControl.Controls.Add(control) If isFirstLoad Then control.EnableViewState = True 'TryCast(control, IASControl).FirstLoad(Nothing) End If Return control End Function Protected Sub RadPanelBar_ItemClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadPanelBarEventArgs) Handles RadPanelBar.ItemClick If e.Item.Level = 1 Then LoadUserControl(P_Body, e.Item.Value, True) End If End SubEnd ClassThe User Control.
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="CompanyList.ascx.vb" Inherits="SystemSetup_UserControls_Setup_CompanyList" %><script language="javascript" type="text/javascript"> function RowDbClick(sender, eventArgs) { var IdCompany = sender.get_masterTableView().get_dataItems()[eventArgs.get_itemIndexHierarchical()].getDataKeyValue("IdCompany"); var W = window.open('Admin/Setup/p_Company.aspx?IdCompany=' + IdCompany, '', 'width=800px,height=550px,resizable=1'); } function Rebind(eventArgs) { var AjaxManager = $find("<%= RadAjaxManager.ClientID %>"); AjaxManager.ajaxRequest('Rebind' + '|' + eventArgs); }</script><telerik:RadAjaxManager runat="server" ID="RadAjaxManager"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadAjaxManager"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid" UpdatePanelHeight="100%" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings></telerik:RadAjaxManager><telerik:RadSplitter runat="server" Width="100%" Height="100%" Orientation="Horizontal"> <telerik:RadPane runat="server" Height="32px"> <telerik:RadToolBar ID="RadToolBar1" runat="server" Height="26px" Width="100%"> <Items> <telerik:RadToolBarButton Text="::" Enabled="false" ></telerik:RadToolBarButton> <telerik:RadToolBarButton Text='<%$ Resources:RTB_New %>' PostBack="false" NavigateUrl="javascript:var W=window.open('UserControls/Setup/p_newCompany.aspx','','width=800px,height=550px')" ImageUrl="../../Resources/Images/ico_New_16.png"></telerik:RadToolBarButton> <telerik:RadToolBarButton Text='<%$ Resources:RTB_Delete %>' ImageUrl="../../Resources/Images/ico_Garbage_16.png"></telerik:RadToolBarButton> </Items> </telerik:RadToolBar> </telerik:RadPane> <telerik:RadPane ID="RadPane1" runat="server" Height="100%"> <telerik:radgrid runat="server" ID="RadGrid" Width="100%" Height="100%" AutoGenerateColumns="false" style="border:0;outline:none;" AllowMultiRowSelection="true"> <ClientSettings> <ClientEvents OnRowDblClick="RowDbClick" /> <Selecting AllowRowSelect="true" /> <Scrolling AllowScroll="true" SaveScrollPosition="true" ScrollHeight="100%" UseStaticHeaders="true" /> </ClientSettings> <MasterTableView style="border:0;outline:none;" DataKeyNames="IdCompany" ClientDataKeyNames="IdCompany"> <Columns> <telerik:GridTemplateColumn> <ItemTemplate> <asp:Image runat="server" ID="I_OnOff" ImageUrl='<%# IIF(Eval("Active") = true,"~/SystemSetup/Resources/Images/ico_On_16.png","~/SystemSetup/Resources/Images/ico_Off_16.png") %>' /> </ItemTemplate> <HeaderStyle Width="24px" /> <ItemStyle Width="24px" HorizontalAlign="Center" CssClass="AbsLeft" /> </telerik:GridTemplateColumn> <telerik:GridBoundColumn DataField="DescrShort" HeaderText="Company"> <HeaderStyle HorizontalAlign="Center"/> </telerik:GridBoundColumn> </Columns> </MasterTableView> </telerik:radgrid> </telerik:RadPane></telerik:RadSplitter>The Rebind javascript is to Rebind the RadGrid. The code behind just says:
Protected Sub RadAjaxManager_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager.AjaxRequest Select Case e.Argument.Split("|")(1) Case "RadGrid" RadGrid.Rebind() End Select End SubThe PopUp that is opened by the User Control:
<%@ Page Title="" Language="VB" MasterPageFile="~/App_Master/SystemSetup/PopUp_1.master" AutoEventWireup="false" CodeFile="p_Company.aspx.vb" Inherits="SystemSetup_UserControls_Setup_p_Company" %><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder_Top" Runat="Server"> <telerik:RadToolBar ID="RadToolBar" runat="server" Width="100%" Height="26px"> <Items> <telerik:RadToolBarButton Value="Save" ImageUrl="../../Resources/Images/ico_Save_16.png" Text='<%$ Resources:WebResources, Save_Text %>'></telerik:RadToolBarButton> </Items> </telerik:RadToolBar></asp:Content><asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder_Left" Runat="Server"> <telerik:RadPanelBar ID="RadPanelBar" Runat="server" Width="100%" AllowCollapseAllItems="True" PersistStateInCookie="True"> <Items> <telerik:RadPanelItem runat="server" Text='<%$ Resources:Menu_Item_1 %>' PostBack="false" Expanded="true"> <Items> <telerik:RadPanelItem runat="server" Value="~/SystemSetup/UserControls/Setup/CompanyList.ascx" Text='<%$ Resources:Menu_Item_1_1 %>' ImageUrl="~/SystemSetup/Resources/Images/ico_Company_16.png" Selected="true"></telerik:RadPanelItem> </Items> </telerik:RadPanelItem> </Items> </telerik:RadPanelBar></asp:Content><asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder_Right" Runat="Server"><div style="position:absolute;top:0px;left:0px;right:0px;height:26px"> <telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage" Width="100%" Height="26px" SelectedIndex="0"> <Tabs> <telerik:RadTab Text="Generale" PageViewID="PV_General"></telerik:RadTab> </Tabs> </telerik:RadTabStrip></div><div style="position:absolute;top:26px;left:0px;right:0px;bottom:0px;"> <telerik:RadMultiPage runat="server" ID="RadMultiPage" Width="100%" Height="100%" SelectedIndex="0" BackColor="White"> <telerik:RadPageView runat="server" ID="PV_General" Width="100%"> <div class="RadPageView_Form"> <div style="width:100%"> <table cellpadding="0px" cellspacing="0px" border="0px" style="width:100%;"> <tr> <td class="Label">Attiva:</td> <td class="Data"><asp:CheckBox runat="server" ID="CK_Active" /></td> <td class="Label"></td> <td class="Data"><telerik:RadTextBox runat="server" ID="RadTextBox2" Width="96%" DisabledStyle-BorderStyle="None" Enabled="false"></telerik:RadTextBox></td> </tr> <tr> <td class="Label">Nome:</td> <td class="Data"><telerik:RadTextBox runat="server" ID="T_1" Width="96%"></telerik:RadTextBox></td> <td class="Label"></td> <td class="Data"><telerik:RadTextBox runat="server" ID="T_2" Width="96%" DisabledStyle-BorderStyle="None" Enabled="false"></telerik:RadTextBox></td> </tr> </table> </div> </div> </telerik:RadPageView> </telerik:RadMultiPage></div></asp:Content>..and the code behind to Update and trigger the Rebind.
Imports System.DataPartial Class SystemSetup_UserControls_Setup_p_Company Inherits System.Web.UI.Page Private IdCompany As Guid = Guid.Empty Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Request.QueryString("IdCompany") Is Nothing AndAlso Request.QueryString("IdCompany") <> "" Then IdCompany = New Guid(Request.QueryString("IdCompany")) End If If Not IsPostBack Then LoadItem() End If End Sub Private Sub LoadItem() Dim oDaOb As New RC.Protection.Company oDaOb.PK.Add("IdCompany", IdCompany) Dim oCo As DataRow = oDaOb.Get CK_Active.Checked = oCo("Active") T_1.Text = oCo("DescrShort") End Sub Protected Sub RadToolBar_ButtonClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs) Handles RadToolBar.ButtonClick Select Case e.Item.Value Case "Save" If IdCompany <> Guid.Empty Then Dim oDaOb As New RC.Protection.Company Dim oCo As DataRow = oDaOb.newDaObItem oCo("IdCompany") = IdCompany oCo("DescrShort") = T_1.Text oCo("Active") = CK_Active.Checked oDaOb.Upd(oCo) Rebind() End If End Select End Sub Private Sub Rebind() Dim Script As String = "window.opener.Rebind('RadGrid');" Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "Rebind", Script, True) End Sub End ClassSo, to make a long story short, First Rebind ....works great...and then non more Rebind till Content Page full reload.
Any ideas ?
Thanks much as always.
Lorenzo