Welcome Guest Search | Active Topics | Sign In | Register

Javascript Options
MRaymond
Posted: Tuesday, May 4, 2010 4:06:10 PM
Rank: Newbie
Groups: Member

Joined: 7/15/2009
Posts: 8
Hello,
I have problems with java script bloc.
I use a CallbackPanel with a progressbar
On the HTML side I had this function

function Start()
{
//Trigger AJAX callback with "start" parameter
eo_Callback("<%=CallbackPanel1.ClientID%> ", "start");
}

With this one I receive a server error
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

I changed eo_Callback("<%=CallbackPanel1.ClientID%> ", "start"); for
eo_Callback("<%#CallbackPanel1.ClientID%> ", "start");

I have no server errror , but when I call the function Start()
I receive the message

"eo.web controls client side debug message
Callback object with ID '' does not exist"


Version Microsoft .NET Framework :2.0.50727.4200; Version ASP.NET :2.0.50727.4016

Thank you

Martin Raymond


eo_support
Posted: Tuesday, May 4, 2010 4:51:11 PM
Rank: Administration
Groups: Administration

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

This is normal. "<%= %>" is the correct syntax. However you can not have this and have code modifying the same control's Control collection at the same time. Move the whole block outside of the control you are trying to modify should be fine. For example, the following code is wrong:

Code: HTML/ASPX
<asp:Panel runat="server" id="Panel1">
    <%=Whatever%>
</asp:Panel>


Code: C#
Panel1.Controls.Add(new LiteralControl("test"));


The following code is correct:
Code: HTML/ASPX
<asp:Panel runat="server" id="Panel1">
    <%=Whatever%>
    <asp:Panel runat="server" id="Panel2">
    </asp:Panel>
</asp:Panel>


Code: C#
Panel2.Controls.Add(new LiteralControl("test'));


The difference is for the first case, the parent control of the "<%= =>" block is the same control that you are trying to add child controls to (both are Panel1), while as for the second case they are not the same (one is Panel1 and one is Panel2).

This is a general ASP.NET rule that has nothing to do with our controls. So it applies to any control.

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.