Showing posts with label ajax. Show all posts
Showing posts with label ajax. Show all posts

Sunday, January 2, 2011

File Upload Ajax Control

It's quite common nowadays using ajax in asp.net development.In recent times many people came to me and complain that file upload is not working.

For example you are using ajax tab control in asp.net page so the controls in your page will come inside the update panel.In that case there will be problem because we will normally set triggers for partial update,this will cause the file upload to fail.

In a normal scenario people will set the ajax update panel like below.

asp:updatepanel id="uppanel1" updatemode="Conditional" runat="server"
//here the we will place the control need to be updated
triggers
asp:asyncpostbacktrigger eventname="SelectedIndexChanged" controlid="ddlState"
triggers
asp:updatepanel
asp:asyncpostbacktrigger


Actually we can set two kind of triggers, one is AsyncPostBackTrigger and Postbacktrigger.One will cause partial update and other will raise normal full post back.

here the trick on tab button click i will fire asynchronus postback trigger . in submit button click i will fire postback trigger.The reason i think already you know, File upload requires full post back if we are doing partial updates then it will not work. This issue will come only when we placed all the controls including submit button also within the update panel.


Hope this will help people to stop cracking the heads
asp:asyncpostbacktrigger eventname="SelectedIndexChanged" controlid="ddlState"
asp:asyncpostbacktrigger eventname="Click" controlid="btnData"
asp:asyncpostbacktrigger eventname="Click" controlid="btnHistory"
asp:postbacktrigger controlid="btnSubmit"
asp:postbacktrigger
asp:asyncpostbacktrigger
asp:asyncpostbacktrigger
asp:asyncpostbacktrigger

asp:updatepanel id="uppanel1" updatemode="Conditional" runat="server"
asp:updatepanel