Welcome Guest Search | Active Topics | Sign In | Register

callbackpanel in a usercontrol Options
Sanchez
Posted: Saturday, February 9, 2008 12:56:11 AM
Rank: Newbie
Groups: Member

Joined: 2/9/2008
Posts: 7
Hello,
i have a callbackpanel (id="cbp_global") in my test page...who is in a masterpage...

i have a usercontrol in my test page
i have a callbackpanel in my usercontrol...

the callback of the usercontrol is fired, but i have this message :

the callback on '....name of de usercontrol' has failed, because the server did not recognize thsi callback and processed it as a normal request

and the panel is not refreshed..

the usercontrol is trigered by this :"this.btsave.Attributes.Add("onClick", "javascript:eo_Callback('cbp_formulaire','save');");" because this :Triggers="{ControlID:btsave;Parameter:save}" doesn't work on my userontrol...


Did someone have a solution, i'm blocked since a fiew days...

thanks,


My test page

Quote:

<%@ Page Language="C#" MasterPageFile="~/Client.master" EnableEventValidation="true" Trace="true" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="sadesys._Pages_Test" Title="sadesys" %>
<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>
<%@ Register TagPrefix="uc0" TagName="tn_client" Src="../Formulaires/Client/CLient.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<eo:CallbackPanel id="cbp_global" runat="server" Width="703px">
<uc0:tn_client ID="formulaire" runat="server" />
</eo:CallbackPanel>
</asp:Content>






My Client.ascx

Quote:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Client.ascx.cs" Inherits="sadesys.Formulaires_Client.Client" %>
<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>
<eo:CallbackPanel id="cbp_formulaire" Triggers="{ControlID:btsave;Parameter:save}" runat="server" Width="703px">
<asp:Panel ID="P_formulaire" runat="server">

<table border="0" width="703px">
<tr>
<td><asp:Label ID="lblRAISOC" runat ="server" CssClass="label" EnableViewState="true" Text="Raison Sociale"></asp:Label></td>
<td ><asp:TextBox ID="txtRAISOC" runat="server" EnableViewState="true" CssClass="input200"></asp:TextBox></td>
</tr>
</table>
<table border="0" width="703px">
<tr>
<td><asp:Label ID="lblMESSAGE" runat ="server" CssClass="message" EnableViewState="true" Text="Message de retour"></asp:Label></td>
<td width="30px"><asp:Image id="btsave" AlternateText="Enregistrer" Width="22px" Height="22px" runat="server" ImageUrl="~/Images/b_save.gif"/></td>
</tr>
</table>

</asp:Panel>
</div>
</eo:CallbackPanel>


my code in Client.ascx
Quote:


private void Page_Init(object sender, System.EventArgs e)
{

this.btsave.Attributes.Add("onClick", "javascript:eo_Callback('cbp_formulaire','save');");
this.cbp_formulaire.Execute += new EO.Web.CallbackEventHandler(this.cbp_formulaire_Execute);
}


private void cbp_formulaire_Execute(object sender, EO.Web.CallbackEventArgs e)
{
//something to do

}
eo_support
Posted: Saturday, February 9, 2008 5:24:49 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

Your code looks fine. One thing you want to check is whether you are loading the user control dynamically. Consider the following sequence:

1. Page1.aspx loads UserControl1.ascx in Page_Load;
2. The page posts back;
3. In order to process the post back events on the server side, ASP.NET reconstructs the page;
4. Based on the post back arguments, ASP.NET locates the control that triggers the postback;
5. ASP.NET triggers the event on that control;

If the control that triggers the postback is in UserControl1.ascx and in step 3, you did not execute the same logic as in step 1 to reload your UserControl1.ascx, you won't see the event triggered. This generally is not a problem if UserControl1.ascx is statically placed inside Page1.aspx, in that case UserControl1.ascx is always loaded along with the page; However if you dynamically load it by code, forget to load it when page post back is one of the most common types of code mistake. When you use CallbackPanel to load user control, it falls exactly into this category.

Generally you should reload whatever you have loaded in Page_Init. You can also take a look of our sample project, check source code in Default.aspx.cs/.vb. And you will see we do the same. All the samples are in user controls and they are loaded dynamically. We use all of our controls inside those user controls and they never have problem. The key is we reload whatever that was last loaded.

Thanks
Sanchez
Posted: Monday, February 11, 2008 10:04:11 AM
Rank: Newbie
Groups: Member

Joined: 2/9/2008
Posts: 7
It's clear, here is the solution, thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.