TextBox text does not change from upload_complete event handler

I have the following code in a downloadable AsyncFileUpload event handler:

Protected Sub AsyncFileUpload1_UploadedComplete(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs) Handles AsyncFileUpload1.UploadedComplete Dim oapp As Excel.Application Dim oWBa As Excel.Workbook Dim oWS As Excel.Worksheet Dim oRng As Excel.Range oapp = New Excel.Application AsyncFileUpload1.PostedFile.SaveAs(Server.MapPath("tempfile2.xlsx")) oWBa = oapp.Workbooks.Open(Server.MapPath("tempfile2.xlsx")) oWS = DirectCast(oWBa.Worksheets(2), Excel.Worksheet) 'Here tns is a textbox contained in a panel tns.Text = Integer.Parse(oWS.Range("W44").Value) + Integer.Parse(oWS.Range("W55").Value) oWBa.Close() File.Delete(Server.MapPath("tempfile2.xlsx")) End Sub 

The autostostback tns property is enabled, so why doesn't it change its text when a file is uploaded? Also, there is no error in the reading logic of the excel file, because I debugged it using VS 2010 and Uptil in the tns.text ... line, I get the correct value in watch.So, how can I get around it?

0
source share
1 answer

Replace the tns.Text property tns.Text in AsyncFileUpload1_UploadedComplete following code:

 var resultString = Integer.Parse(oWS.Range("W44").Value) + Integer.Parse(oWS.Range("W55").Value); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "result", "top.$get(\"" + tns.ClientID + "\").value = '" + resultString + "';", true); 

PS is a workaround and much more you can find on the example site AjaxControlToolkit, available for download from codeplex

0
source

All Articles