My app provides a view of validated items from the uploaded files.
I need to bind a grid/listview after files uploaded but when I do it after the uploadfinished event its too late.
If I do a postback to the existing page I lose the list of files in the upload view.
Suggestions?
Hello Daniel,
Thank you for posting in the community.
What I can suggest for achieving your requirement is to use __doPostBack function to trigger a postback once FileUploading client-side event is fired. The __doPostBack function takes two arguments, eventTarget and eventArgument. The eventTarget contains the ID of the control that causes tha postback and eventArguments contains any additional data associated with the control(some further reference about __doPostBack function could be found at: http://aspalliance.com/articleViewer.aspx?aId=895&pId=-1 ).
In your scenario what could be done is to trigger a postback when FileUploading event is fired. Afterwards in the PageLoad event of the page it could be checked whether the eventArgument from the __doPostBack is the same that is set for the FileUploading event and if so rebind the grid. For example:
client-side: WebUpload1_FileUploading(eventArgs, infoObject) { __doPostBack("up1", "fileUploaded"); } code-behind: protected void Page_Load(object sender, EventArgs e) { if (Request["__EVENTARGUMENT"] == "fileUploaded") { //bind your control here }
client-side:
WebUpload1_FileUploading(eventArgs, infoObject)
{
__doPostBack("up1", "fileUploaded");
}
code-behind:
protected void Page_Load(object sender, EventArgs e)
if (Request["__EVENTARGUMENT"] == "fileUploaded")
//bind your control here
I hope you find this information helpful.
Please do not hesitate to contact me if you have any additional questions regarding this matter.
Thanks for your reply.. I tested something similar but if I do post back at this time on file uploading will I have two threads going? one still processing the file and the postback that needs to wait until the file finishes?