Asked by:
After opening the report how to refresh the form to show the update values in VB.NET

Question
-
User-1578974752 posted
In my vb.net button click,
1 stored procedure call (change the status of the form to Approved) ,1 email , 1 report with Open option as below
Response.AppendHeader("Content-Disposition", ("attachment; filename=" + Path.GetFileName(String.Format("C:\inetpub\wwwroot\Ttt\Ttst\Reports\Slip\SlipReport{0}.pdf", Convert.ToString(delsearch.Text)))))
' Response.Redirect(Request.RawUrl)
Response.WriteFile(String.Format("C:\inetpub\wwwroot\Ttt\Ttst\Reports\slip\SlipReport{0}.pdf", Convert.ToString(delsearch.Text)))
and at last
Response.Redirect(Request.RawUrl)
My issue is ,If I place Response.Redirect(Request.RawUrl), updated status is showing in the form ,but the report ,Response.WriteFile is not happening.
If I avoid ,Response.Redirect(Request.RawUrl) ,then report is opening but status of the form is not changing.
How can I make such that report will open and the form will refresh so that the Approved status will be shown. Appreciate the help as I am struggling for this for long time..
Thanks
Friday, January 3, 2020 9:05 AM
All replies
-
User281315223 posted
By default, ASP.NET will take any Response.Write / Response.Redirect methods and immediately flush the response using that approach. So you have to choose to either explicitly use either `Response.Redirect()` or `Respone.WriteFile()` on their own.
Do you have any additional code related to this? One consideration might be to explicitly update your file (instead of using `Response.WriteFile()`) and then after it's been updated, set to to be appended via an attachment header as you currently are.
Friday, January 3, 2020 9:00 PM -
User-1578974752 posted
Actually, the stored procedure, will update the status in grid view and the form.
Explicitly update your file-> Can pls inform how to implement this.
Thanks
Monday, January 6, 2020 2:17 AM -
User288213138 posted
Hi shsu,
My issue is ,If I place Response.Redirect(Request.RawUrl), updated status is showing in the form ,but the report ,Response.WriteFile is not happening.Do you want to execute the Response.WriteFile () method after refreshing the page?
If so, you can try to use javascript function location.reload() to refresh the page.
<script> function refresh() { location.reload(); } </script> Response.AppendHeader("Content-Disposition", ("attachment; filename=" + Path.GetFileName(String.Format("C:\inetpub\wwwroot\Ttt\Ttst\Reports\Slip\SlipReport{0}.pdf", Convert.ToString(delsearch.Text))))) ClientScript.RegisterStartupScript(this.GetType(), "refresh", "refresh();", true); Response.WriteFile(String.Format("C:\inetpub\wwwroot\Ttt\Ttst\Reports\slip\SlipReport{0}.pdf", Convert.ToString(delsearch.Text)))
The Response.Redirect() function will cause the code to stop executing by throwing a System.Threading.ThreadAbortException.
Best regards,
Sam
Monday, January 6, 2020 9:16 AM -
User-1578974752 posted
Thanks, I am using vb.net . Here this is showing error in ClientScript.RegisterStartupScript(this.GetType(), "refresh", "refresh()", true) when I tried as
ClientScript.RegisterStartupScript(this.GetType(), "refresh", "refresh()", true)
Can help to covert to vb.net please. Telerik coverter showing error.
ClientScript.RegisterStartupScript(this.GetType(), "refresh", "refresh();", true);
Tuesday, January 7, 2020 9:52 AM -
User288213138 posted
Hi shsu,
Can help to covert to vb.net please.Try this code:
ClientScript.RegisterStartupScript(Me.GetType, "refresh", "refresh();", True)
Best regards,
Sam
Tuesday, January 7, 2020 9:59 AM -
User-1578974752 posted
still not working. Report is opening but refreshing page is not happening.
Wednesday, January 15, 2020 1:23 AM -
User288213138 posted
Shsu,
Report is opening but refreshing page is not happening.Please debug your code to see if ClientScript.RegisterStartupScript (Me.GetType, "refresh", "refresh ();", True) is triggered.
Best regards,
Sam
Wednesday, January 15, 2020 1:44 AM -
User-1578974752 posted
actually ,Debugger is going through that code with out any error.
Wednesday, January 15, 2020 2:55 AM -
User288213138 posted
Hi shsu,
actually ,Debugger is going through that code with out any error.<script> function refresh() { location.reload(); } </script>
This js function is also called? can you share your complete code?
Best regards,
Sam
Wednesday, January 15, 2020 3:04 AM -
User-1578974752 posted
<script type="text/javascript">
function refresh() {
location.reload();
}
</script>
Response.AppendHeader("Content-Disposition", ("attachment; filename=" + Path.GetFileName(String.Format("C:\inetpub\wwwroot\zxc\zxyService\Reports\Slip\SlipReport{0}.pdf", Convert.ToString(delsearch.Text)))))
ClientScript.RegisterStartupScript(Me.GetType, "refresh", "refresh();", True)
Response.WriteFile(String.Format("C:\inetpub\wwwroot\wwwroot\zxc\zxyService\Reports\Slip\SlipReport{0}.pdf", Convert.ToString(delsearch.Text)))
Other codes are email trigger and 2 sp calls. only the report opening code was having the issue with refreshing the page.
Wednesday, January 15, 2020 3:08 AM -
User288213138 posted
Hi shsu,
Response.AppendHeader("Content-Disposition", ("attachment; filename=" + Path.GetFileName(String.Format("C:\inetpub\wwwroot\zxc\zxyService\Reports\Slip\SlipReport{0}.pdf", Convert.ToString(delsearch.Text)))))
ClientScript.RegisterStartupScript(Me.GetType, "refresh", "refresh();", True)
Response.WriteFile(String.Format("C:\inetpub\wwwroot\wwwroot\zxc\zxyService\Reports\Slip\SlipReport{0}.pdf", Convert.ToString(delsearch.Text)))
Are these methods in the button click event? If so, the page will keep refreshing.
How can I make such that report will open and the form will refresh so that the Approved status will be shown.Your code is to refresh the page and then Response.WriteFile. Does this make any sense? Or do you have other special needs?
Can you tell me how did you display the approved status?
Best regards,
Sam
Thursday, January 16, 2020 4:03 AM -
User-1578974752 posted
Hi
If response.rawurl I didn't specify then ,I cannot show the updated values in the form.[Because -> from summary form I am showing lot of values In to the current form which user will update with the button click.
but
Response.WriteFile(String.Format("C:\inetpub\wwwroot\wwwroot\zxc\zxyService\Reports\Slip\SlipReport{0}.pdf", Convert.ToString(delsearch.Text)))
is preventing the refreshing.
Friday, January 17, 2020 2:00 AM -
User288213138 posted
Hi shsu,
Response.WriteFile(String.Format("C:\inetpub\wwwroot\wwwroot\zxc\zxyService\Reports\Slip\SlipReport{0}.pdf", Convert.ToString(delsearch.Text)))The button click event will refresh automatically, please show me how do you update the value?
Best regards,
Sam
Friday, January 17, 2020 7:36 AM