Welcome Guest Search | Active Topics | Sign In | Register

ProgressBar on dynamically loaded UserControl does not work Options
Olivier
Posted: Thursday, June 26, 2008 12:11:32 PM
Rank: Newbie
Groups: Member

Joined: 6/26/2008
Posts: 3
Hello,

I use user controls which I load dynamically if they are needed with the following command:
Code: C#
PlaceHolder1.Controls.Add(LoadControl("~/Trainer/WebUserControl.ascx"));


If I load my usercontrol (containing the eo progressbar) at Page_Load everything works fine. But if I load the usercontrol later on, I get an error 'object expected'.

Additionally I found out that if I remove the properties which contain pathes for the image files, then it works too. Probably this may help somehow.

Thanks in advance,
Olivier
eo_support
Posted: Thursday, June 26, 2008 12:20:42 PM
Rank: Administration
Groups: Administration

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

That is quite normal. Generally when you use dynamic control loading, you must load it again exactly as it was when the page posts back in order for view state and server events to function properly. This post should provide more information/links about this issue.

http://essentialobjects.com/Forum/Default.aspx?g=posts&t=1179#5018

In fact you may want to consider loading the dynamically loading controls as early as Page_Init instead of Page_Load. Our sample projects demonstrate this technique. You may want to take a look of that. Check source code in Default.aspx.cs.

Thanks
Olivier
Posted: Thursday, June 26, 2008 12:50:51 PM
Rank: Newbie
Groups: Member

Joined: 6/26/2008
Posts: 3
Hi,

thanks for your prompt response. Unfortunately, I can't really follow even after reading your suggested posts.

What I have:
Application.aspx: Menu + Panel & Callback Panel
If I click on a menu entry a callback server-side function will be called. This function loads an external user control dynamically. That works perfect.

The problem is that I get this error 'object expected' when I load the user control dynamically with your progress bar on it. Without the progressbar it works again.

So my question, what do I have to do to get it work? Please explain in details. An example project may be very helpful.

Regards,
Olivier
eo_support
Posted: Thursday, June 26, 2008 1:17:14 PM
Rank: Administration
Groups: Administration

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

The sample is actually already there. The whole sample project, which is provided in both VB and C# along with Visual Studio project files uses exactly the same mechanism to load demos. Each demo is a user control and when you click a TreeNode on the left side, it triggers a CallbackPanel and load the user control on the right side.

What makes it a bit difficult is that this is not something as simply as a property to set, it's a whole mechanism that you will want to understand in order to avoid any further trouble. The issues itself is an advanced ASP.NET topic and it just happens that you run into it with our ProgressBar (in that regard it's actually technically out of the scope of our support). The linked that we provided explained this issue in great detail. You would visit the link (don't just click it, if you click it it dropped the last part "#5018", so copy and paste the full Url into your browser) and you will see two more links. The first link explains this issue in a step by step fashion and that should help you understand what's going on. The other link along with the whole thread provides some more information about this issues. The other user hit this with the CallbackPanel, not the ProgressBar, but what's beneath is exactly the same.

Hope this helps!

Thanks
Olivier
Posted: Saturday, June 28, 2008 2:53:56 AM
Rank: Newbie
Groups: Member

Joined: 6/26/2008
Posts: 3
Hello,

WebPage.aspx
Code: HTML/ASPX
<eo:ProgressBar ID="ProgressBar1" runat="server" Width="250px" />


WebUserControl.ascx
Code: HTML/ASPX
<eo:ProgressBar ID="ProgressBar2" runat="server" />


I have a button on WebUserControl.ascx which sets the value of the ProgressBar2. For this I tried to use the following code:
Code: JavaScript
eo_GetObject('ProgressBar2').setValue(50);


It doesn't work. I get the error 'null' oder null is no object. If I try to get access to the ProgressBar1 it works. What do I have to change?

Thanks, Olivier
eo_support
Posted: Saturday, June 28, 2008 10:00:28 AM
Rank: Administration
Groups: Administration

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

That usually occurs when the ID that you pass to eo_GetObject does not exist. For example, if the ID of the ProgressBar is "ProgressBar1", and you call eo_GetObject("ProgressBar2"), you will get that error. As for user control, we verified the following steps and it works fine:

1. Start a blank new page;
2. Create a new user control;
3. Place a ProgressBar inside the user control;
4. Place the user control directly in the web page;
5. Try the same JavaScript and see if you get the error;

Please try the same and if you do not get the error message, then the problem is related to your code, most likely has to do with your dynamic loading code. If that's the case, you will need to seek other resource to resolve the issue as our support does not cover user code error:

http://www.essentialobjects.com/Forum/Default.aspx?g=posts&t=1368

If you get the error message by following the same steps, then check the version you are running and make sure you are running the latest version.

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.