Monday, March 26, 2012

Will atlas:updatepanel and asp:fileupload ever be friends?

Just wondering if there ever will be support for postbacks inside a updatepanel.

Possible by adding a mode "Triggered" to the updatepanel's Mode list.
This mode could make the updatepanel only update when it's triggered by a trigger from the trigger list, or by myupdatepanel.update();

hello.

well, i'd say no you won't be able to do that. i guess that the problem is that you can't get the bytes from the input type="file" with jscript...


I know it's not possible in the current build :\

Just wondering if there is any planes to make this happen in any of the next atlas builds..
Or is it simply not possible to not trigger atlas within the updatepanel when triggering a postback?

hello.

what i was trying to say was that the problem was not related with the current build but with the way the <input type="file"> works. if i'm not mistaken, you can't get the bytes of the file by using javascript. due to this, atlas won't be able to get them too since what it does (when it performs a postback) is to go through all the controls of the form and get their values which are packed on a string that is sent back to the server. since you can't get the bytes of the file through javascript, i think that what you wask won't be possible ...though i hope i'm wrong ;)


Yes i understand that :)
But what i was hoping for, was a atlas:updatepanel mode, that enabled it to only do the javascript postback if a atlas trigger was used, or a updatepanel.update();

This would enable all controls that do a normal postback but are't stated in the triggers list, to send a normal postback.

Good example of my problem now:

My page is build up so if the user logs in, his options pops up without page refresh.
This is a picture gallery and when you log in, you can see "new album, new picture" etc..

The problem here is that i can't get the UploadPanel to be visible, since the "new picture" button is inside a updatepanel, and the uploadpanel is't.
And I cannot upload a picture if the uploadpanel is inside a atlas:updatepanel cause it won't send the file :s

So either I need to be able to run a normal postback inside a updatepanel, without atlas taking over the event, or I can't view the "new picture" link before the page has been refreshed one time.

hello.

i didn't understand the visibility problem associated with the updatepanel. can you show me the declaration of the udpatepanel? how are you hiding it? i hope that you're using css styles to do that (if you're using the visible property i'm willing to bet that the control isn't being rendered on the final page


hello.

i didn't understand the visibility problem associated with the updatepanel. can you show me the declaration of the udpatepanel? how are you hiding it? i hope that you're using css styles to do that (if you're using the visible property i'm willing to bet that the control isn't being rendered on the final page)


For now i've been using a asp:panel with visibilty value inside a updatepanel.
And then used panel.visible = true; and updatepanel.update();

With the sample code here.
Your just logged in, and you now get to view the linkbutton "Upload".
The linkbutton needs to be inside a updatepanel, since it could be displayed without pagerefresh when the user logs in.
Since it's inside a updatepanel, it can only trigger atlas postbacks, and no refreshed postbacks.
Therefore my uploadpanel also needs a updatepanel wrapped around, so it will be visible when you push the upload linkbutton. (again without page refresh)
But since the fileupload is inside a updatepanel, the fileupload won't do a real postback, and therefoer the file is't uploaded..

Solutions:
Is there a way to get the fileupload to do a valid postback, even tho it's inside a updatepanel?
Is there another way to display my fileuploadpanel with or without pagerefresh from a linkbutton within a updatepanel?

Very simple code:

<atlas:UpdatePanel ID="UploadLinkUpdatePanel" runat="server" Mode="Conditional"> <ContentTemplate> <asp:LinkButton ID="Upload" runat="server" Text="Upload" OnClick="Upload_Click" /> </ContentTemplate></atlas:UpdatePanel><atlas:UpdatePanel ID="FileUploadUpdatePanel" runat="server" Mode="Conditional"> <ContentTemplate> <asp:Panel ID="FileUploadPanel" runat="server" Visible="false"> <asp:FileUpload ID="FileUpload" runat="server" /> </asp:Panel> </ContentTemplate></atlas:UpdatePanel>
protected void Upload_Click(object sender, EventArgs e) { FileUploadPanel.Visible =true; FileUploadUpdatePanel.Update(); }

hello.

several things here: 1st, i'd use only a panel (or even a simple div control) to hide the uploadfile control. when you set the visible property of a control to false, that control will not generate HTML that is sent to the client. this is not probably what you want...

setting the mode of the updatepanel to conditional will also have different results here. this means that only one panel will be refreshed and this can be caused by a server side event fired by a control placed inside the panel or by an external control configured as a trigger.

so, in this case, i'd do the following:

1. remove the 2nd updatepanel

2. configure the visibility of the panel without using the visible property (use the css disply property)

3. use the postbackaction associated with the button (yes, use the xml script) and set it so that the target is the link button (since i haven't tried it, i'm having some doubts about this...it might not work very well...you might have to add a dummy button outside the panel so that it really makes a complete postback)

hope this helps.


First of, Can i hide\show a panel\div without using atlas?
If this is possible (without refreshing the whole page), then i might be able to do a workaround..

I'm using all these updatepanels with panels inside, so that when a user logs into my gallery, the list of albums\pictures in the current album is updated according to the users permissions,
But also admin stuff is visible, like create album etc..

All this happens without the page refreshing at all, and it's looking pretty nice :)
So the only problem now is to get the fileupload to post (and work)..

I want to have it inside a updatepanel so i can display the form without page refresh, but atm i have no idea what to do :\

PS: Demo page ishttp://vakuum.mine.nu (VERY slow)


hello.

well, you can hide/show the panel without updateanel. the updatepanel is cool because it let's you handle server side events without doing a complete postback. to show/hide an element you don't need an update panel. if i'm not mistaken, the asp.net panel control generates a div element. since you know its id, then you can simply write this javascript code to hide the panel:

document.getElementById("id of the asp.net panel").style.display = "none";

and to make it visible, just do something like this:

document.getElementById("id of the asp.net panel").style.display = "block";


Thanks =)
That just solved half of my problem :)

Now i need to set display = "none" if any other button is clicked.. guessing that will be hard :\
Hi, I have some kind of similar problem with a filupload control and updatepanels. So I wrote script to hide the fileupload on the pageload, and show/hide it whenever I need it.
I used page.registerstartupscript("shide, strshowhidescript") on every place I need it, but it never works when I call it in the method that handles an event from a button that's in the update panel. the code from that button works when I do step into, but On the screen there are no change, not even from the other code in that button which worked before I added the script. Any idea how I can overcome this?
thx.

hello.

can you show the client script code you're registering? thanks.

No comments:

Post a Comment