I'm writing a page in asp.net to post something to a website and I'm trying to add a preview button to the page. The problem with the code lies in popping up a window containing the preview. The onClick event of the asp:button runs a subroutine to create a new text file, 'temp.txt' (using a Try... Catch statement). Once this is done, I have added the following line:
message.Text = "<script language=Javascript>window.open('disp_report.asp?temp.txt');</script>", where message is an asp:label. This results in a Compilation Error saying 'Try statement must end with an 'End Try', almost as if the line of code was an unterminated string. Commenting out the line (with a ') results in the same error.
Any ideas?
Last edited by olamm2k; Jan 7th, 2006 at 03:52 PM.
Here's the page (attached). The line of code I mentioned is commented out at the bottom of the Preview_Click subroutine. It still causes the error, though. For the moment, I've got the message label showing a hyperlink to view the preview, which is a bit messy, but works.
Okay, building up the string gradually has shown that the problem seems to be with the final ">". However,
Code:
Dim strScript As String
strScript = "<script language=Javascript>window.open('disp_report.asp?temp.txt');</script" & ">"
Page.RegisterStartupScript("script1", strScript)
seems to work.
Weird...
This still isn't giving me a popup, either. Searching the page source after the button has been clicked shows that the script is there, right after the 'Temporary match report created...' on the page. Any more ideas?
**Edit**
Turns out, the popup works fine - Norton Internet Security is just blocking it! Any way round this? I'm still having the Italian calendar problem, too.
Last edited by olamm2k; Jan 7th, 2006 at 02:52 PM.
Norton Internet Security is the culprit. Is there any way round this? I can add an exception on my computer, but it's not really feasible for everyone visiting using Norton to do.
I'm still getting the Italian calendar from time to time, too!
For the first part, do you really need the popup to open when the page reloads, or can you have it when the user clicks on the link? Things could be easier if it's on the link click.
For the second part, how Italian is it? Is it romancing you?
My regional settings are fine. It's just bizarre that the calendar control is only sometimes Italian... It's something like 1 time in 5 that it appears like that!
**Edit**
The following lines of code seem to have fixed it:
VB Code:
Sub Page_Load()
Dim lang As System.Globalization.CultureInfo
lang = New System.Globalization.CultureInfo("en-gb")
System.Threading.Thread.CurrentThread.CurrentCulture = lang
System.Threading.Thread.CurrentThread.CurrentUICulture = lang
End Sub
Back to the original question - can you think of a reason why I had to concatenate on the last '>' like that?
Last edited by olamm2k; Jan 7th, 2006 at 03:52 PM.
Well, I suppose I should mark this resolved. We got the popup going, although no resolution about that last '>'. I've actually seen that in some code before - where it's added on at the end, but there was no explanation as to why. I just thought, 'that looks pointless...' and left it at that.