2009년 02월 20일
[AJAX] UpdatePanel에서 FileUpload Control 사용하기
- 해당 글은 http://muraton.net/post/2008/01/FileUpload-and-Ajax-UpdatePanel.aspx 의 글을 발로번역하였습니다. -
All file upload controls (includes asp, telerik, componentart, component factory and others) does not working in any ajax update panel and upload control needs to full page postback.
모든 파일 업로드 컨트롤(asp, telerik, componentart, component factory 등에 포함된)들은 Ajax의 UpdatePanel안에서 사용하고자할때는 페이지 전체를 postback 시켜야 합니다.
This means if your upload control located in an update panel, control does not post the file.
이것이 의미하는것은 UpdataPanel 안에 FileUpload컨트롤을 위치시킬경우 해당컨트롤로 파일을 업로드 하지 못합니다.
If you look to the posted file property of the control, you will see it null.
해당컨트롤로 파일업로드하는것을 살펴보면 해당 컨트롤의 파일속성이 null로 되는것을 보실수 있습니다.
So, the control always have to post full page postback.
그래서 해당컨트롤은 항상 페이지전체를 postback시켜줘야 합니다.
This is a limitation comes from the XmlHttpRequest component, used in all AJAX frameworks for asynchronous calls to the application.
이것은 비동기식 호출인 XmlHttpRequest 한계에서 드러나는 것입니다.
In order to upload a file you should perform a full page postback.
순조롭게 파일을 업로드하려면 전체페이지를 postback시켜야 합니다.
If you have automatically AJAX-enabled button or other control, which normally does postbacks, placed in UpdatePanel you could use one of following workarounds to make the button to perform postbacks again.
AJAX버튼 또는 다른컨트롤이 자동으로 postback을 일으키지는 않으므로 다음중 하나를 사용하므로써 UpdatePanel에 위치한 버튼으로 postback을 일으킬수 있습니다.
1 - You need to create a PostBackTrigger for the button which should initiate postback.
<asp:updatepanel runat="server" id="UpdatePanel1"> <contenttemplate> <asp:FileUpload runat="server" id="Upload1" /> <asp:button runat="server" id="ButtonSubmit" text="Postback" /> </contenttemplate> <triggers> <asp:postbacktrigger controlid="ButtonSubmit" /> </triggers> </asp:updatepanel> |
2 - You can register the page and control to do full page postback. To do this, you can use the script manager.
2 - 전체 페이지를 postback시킬 페이지와 컨트롤을 등록할수있습니다. 이 방법을 사용하려면 스크립트 매니저를 사용합니다.
ScriptManager.GetCurrent(Page).RegisterPostBackControl(Upload1); |
3 - You can use the "iframe" html object to call upload webpage in frame. But this as you know iframe is not a XHTML object. But this can be smooth fix for you.
3 - 웹 페이지를 호출하려는 프레임에 iframe html객체를 사용할수 있습니다. 하지만 iframe은 XHTML객체가 아닙니다. 하지만 프로그램의 수정을 통해 사용할수 있습니다.
결과적으로 iframe을 쓰려면 코딩삽질이 필요하다는소리네..-_-;;
# by | 2009/02/20 17:43 | 프로그래밍이야기 | 트랙백 | 덧글(1)






☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]