postback pageupdate

Apr 21, 2009 at 1:46 PM
Edited Apr 21, 2009 at 3:22 PM
Hi Flaxajian,

I know you are getting a lot of questions about this.

I am making an image selection device for an e-commerce cms system. It is much more complex than a straight page for users uploading images.

When a file is received I need to handle this event as a postback and add an additional node to a treeview control, on the fly. The uploader is sitting in an ajaxToolKit modalPopupExtender panel and I need to close the panel also at the same time. I then need to display the uploaded image in an imagebutton.

All of this is sitting inside an updatePanel.

OK, so I know this is an ajax and flash control, and I have read that there is no postback, so you can't modify the parent page.

But there is a postback. With the RequestAsPostBack property set to "true", the FileReceived event has access to the viewstate and web control property values.

It is possible to update those web controls. I can add a new node to the treeview, populate the image and hide the panel, none of which affects the clientside state of the controls. All these elements are sitting within an update panel and I can set the update panel to update, but still it does nothing on the client side itself. 

So what does the RequestAsPostBack property do? I would have expected the postback event to be able to update all the content of an updatePanel if it is sitting in one, especailly as I have the UseInsideUpdatePanel property set to "true". Is there really no way when on the server the event FileReceived  is called the updatePanel in which the uploader sits cannot also be updated?

This is such a good control. Probably the best I can find, but this problem really makes it difficult to incorporate in a complex application.
Any help would be really appreciated.

Apr 21, 2009 at 4:18 PM
You have to use client side event in a similar way like the one described here and then perform your changes from there. The control is not part of Ajax Toolkit so you can't expect it to work within it's model. I am surprised that now when you have all the sweetness of jQuery people still use Ajax Toolkit.
Apr 21, 2009 at 5:09 PM
Edited Apr 21, 2009 at 5:29 PM
yes, I tried the client side event to simulate a postback after an update, but it caused a series of javascript errors in the ajaxtoolkit and the telerik controls I am using.

jQuery... actually I hadn't heard of it. Too busy working on projects to have heard of every new thing on the block. Especially as I work in a microsoft technology RAD environment which is usally the antithesis of open source. We just need quick and reliable drag and drop controls, that are going to enhance our developments.

Actually the control works perfectly well with the Ajax toolkit's modalPopupExtender. That isn't the problem. I have tested the control on a page without any control other than a .net label. It is just seems to be a feature of the control.

When the control posts back, it fires the FileReceived  serverside event. If the RequestAsPostBack property set to "true", in the FileReceived event code the viewstate properties and control properties are exposed. 

At the end of the server side event there is no return to the client at all it seems, no response.

Anyway... if anyone is interested. There is a way to get this to work in a simple environment.. although for me at the moment it is still causing problems.

RequestAsPostBack property set to "true"
In the FileReceived  event save all details of the upload to session variables.
put a linkbutton on the page and set it's style="display:none;" id="lbPostback"

<script type="text/javascript">
    function fn_fileStateChanged(uploader, file, httpStatus, isLast) {
        Flajaxian.fileStateChanged(uploader, file, httpStatus, isLast);
        if (file.state > Flajaxian.File_Uploading){
            document.getElementById("<%= lbPostback.ClientID %>").click();

And then handle the webcontrol changes in the linkbutton click event.

Seems to need 2 postbacks to achieve the desired result though. One from the control and one from the linkbutton. If the linkbutton and other controls are in an UpdatePanel it will do this without a full page postback.


May 14, 2009 at 4:39 PM

Awesome - thanks for this solution.  I was struggling with almost the exact same thing, and was close but had not gotten the right javascript function yet.  I love the uploader control and know it's designed to upload without postbacks, but having a property one could set to allow it to function like a regular asp:button in certain cases would be a great enhancement.

May 26, 2009 at 6:30 AM

This javascript function seems to work for me on IE, but not Firefox or Safari.  Any ideas?  Thanks.

May 26, 2009 at 1:57 PM

Yes, that is correct. the .click() function is an IE only thing.

If you know your jQuery you will be able to use the .click() function for all browsers, otherwise you will have to provide conditional javascript and use the .onclick() for firefox, and also use an server control to postback that keeps its postback javascript in its onclick event..

But you can continue to use a .net linkbutton. Look at the href on your  lbPostback control at run time. Take that and put it in an onclick event.