This project is read-only.

Usercontol Callback not working in Post

Topics: ASP.NET 2.0, Controls
Mar 16, 2008 at 6:43 PM
I have been developing a web user control to inject into my posts. I followed the steps in the following post: My user control worked fine as long as I didn't use the AJAX Updatepanel as suggested in the previous post. When I did use the UpdatePanel the control rendered but as soon as the panel posted back, the control was replaced with a red cross.

The post suggest to use callbacks instead of postbacks. I implemented the usercontrol by using callbacks and everything works fine when I test the control in a seperate page. The problem is that as soon as I embed the control in a post the callback does not fire.

The WebForm_DoCallback() function gets called but it seems that the call just dissapears as nothing happens. I see that the name of the control passed to the callback is different when I embed the control in its own page and when I embed it in the post. This makes sense since the page structure is different because of the post. I also think that this is probably where my problem lies since the call back to the control gets lost.

Any help or suggestion would be appreciated.

Mar 16, 2008 at 8:52 PM
I never got far enough with the understanding of the code to figure out how to make an AJAX callback work- but I got as far as you did in discovering that the update panel route does NOT work... what a shame.

Outside of an update panel, there is more overhead associated with coding the callback than with my usercontrol's code (in my case).

The only thing that I might be able to offer is a derivative of Mad's suggestion: inspect the code involved in posting a comment- which uses the callback technique- maybe you are having a conflict with controls or names involved with the comment system?
Mar 16, 2008 at 9:10 PM
Thanks for the reply Dan,

I managed to make it work inside the post.

The problem was that the class name of the page I used to test the user control and the class name of the usercontrol was the same. I am guessing this caused some problems, since I corrected the mistake, the control works inside the posts.

Mar 16, 2008 at 9:18 PM
Edited Mar 16, 2008 at 9:18 PM
I spoke to soon...

The callbacks work when I view the post at its permalink where it is the only post on the page. The callbacks still won't work when there are multiple posts, like on the homepage.

Again... any suggestions would be appreciated.