Last post Jan 06, 2017 02:40 AM by Cathy Zou
Jan 05, 2017 03:42 AM|kaiclassic|LINK
I have two functions. One is Print. Another is Export. Yes user select at least one row of data from GridView (returned from database) and either Print or Export (or even one after another)!
In the Print function, I use Page.ClientScript.RegisterStartupScript() to pop up another page for print processing. Eventually that will allow user to download a newly generated file.
Page.ClientScript.RegisterStartupScript(Me.GetType(), "OpenPrintWindow", "window.open('PrintForecast.aspx', '_newtab');", True)
Test the Print. Works ok. (Get the HTML file.) Then add to the Export function:
Page.ClientScript.RegisterStartupScript(Me.GetType(), "OpenExportWindow", "window.open('ExportForecast.aspx', '_newtab');", True)
Test. (F5 to bring up the page.) I make sure I step into the Export function, and it actually steps pass the RegisterStartupScript(). All I get is as if I call the PrintForecast.aspx! (I get the HTML file instead of CSV file I want.)
What is happening? I even use different keys (OpenPrintWindow and OpenExportWindow)!!!
Jan 05, 2017 04:53 AM|kaiclassic|LINK
Sorry about that. I actually made a mistake. I copy the Export page (both .aspx and .aspx.vb) from Print page! So the Export.aspx is actually referring to Print.aspx.vb!!! So whenever I want to export, it actually call Print.aspx.vb to handle.
In summary, Page.ClientScript.RegisterStartupScript() can be registered more than one time
in a single ASPX page. Just make sure the key (the second parameter) is different in each registration.
reminder in Stack Overflow says so.)
Jan 06, 2017 02:40 AM|Cathy Zou|LINK
From your description. it seems that you have solved your problem,
Thank you for your sharing about your solution, which will be helpful for others