Show error information in web form while generating document - javascript

I have an ASP.NET web page that is called from JavaScript using:
window.open( url, '_self', ...
This ASP.NET page generates on the fly an Excel worksheet so the browser starts downloading it and then opens Excel when it is finished without leaving the caller web page (the one with the JavaScript function).
Now I want to handle all posible errors that might happen while generating the Excel document, catching the exceptions in ASP.NET and showing some error information in a JavaScript alert dialogbox.
I have tried adding in the catch block the following:
Response.Write("<script>alert('Error while generating Excel
> worksheet');</script>");
but after accepting the alert window, the browser remains in a blank page. In that situation, I would like to close the alert and remain in the calling web page in the same state as it was when it called the Excel generation ASP.NET page through JavaScript. I have tried using history.back() but this reloads the web page losing all changes the user might have done previuosly there.

Related

Duplicate Security Warning In Adobe PDF

My object is to automatically open a URL whenever a user opens a PDF inside Adobe Acrobat. I am using PyPDF2 to inject javascript inside the PDF only once
addJS('app.launchURL(URL,true);')
It's working fine but the issue is that is am getting security warnings twice .
I want this message to appear only once but we don't recommend users to select Remember this action for the site as the URL will be dynamic for every user.

Why does this URL do different things depending on how it's activated?

In a related post (here) I discuss a problem I'm having with a URL action in a SQL Server Reporting Services report. I thought I had solved the problem, but I now realize that I haven't. (I'll update the related post in due course.)
I'm generating a URL using string concatenation, and using Javascript so the URL opens in a new browser tab. Here's the code that generates the URL, which I think is pretty standard:
="javascript:void(window.open('http://www.ic.gc.ca/app/opic-cipo/trdmrks/srch/viewTrademark?id="
+ Fields!applicationNoWithExtn.Value
+ "&lang=eng&tab=reg','_blank'))"
And here's an example of the URL that's generated when a value is inserted:
http://www.ic.gc.ca/app/opic-cipo/trdmrks/srch/viewTrademark?id=159511-00&lang=eng&tab=reg
The generated URL works. It takes you to an online database web page for a Canadian trademark having application number 159511-00 (you don't see the "-00" suffix on the web page, but it's the correct application number).
The problem is that when the user clicks the generated URL, the browser's print dialog opens immediately after the web page opens. That's very distracting; the user has to click Cancel to dismiss the print dialog. If the web page is reloaded or refreshed within the browser, the browser's print dialog opens again. However, if I copy the URL and paste it into a new browser tab, I get the desired web page without the print dialog. I don't get it; it's the identical URL, but the version of the URL generated by my application somehow triggers the print dialog, whereas a copy/pasted version of the identical URL doesn't. I've tried different browsers (Chrome, Edge and IE) and different machines, but I keep getting that print dialog when I click the URL generated by my application. If I change the code to generate a standard URL like http://google.com the generated standard URL works without triggering the print dialog. So the problem seems to be with the particular web site that I am accessing via the concatenated URLs shown above.
Can anyone explain what's going on and how I can suppress that print dialog?

FileMaker script executed from web viewer via XML on click event causing web viewer refresh

I am building a filemaker app that will be used in web direct only. There is a custom web map displayed in a web viewer window. I have written javascript that passes a parameter into a filemaker script (and executes it) via an XML URL based on where the user clicks on the map.
Everything is working fine, except that whenever the test script executes, the web map in the web viewer refreshes. I know that it is something in FileMaker (not in the JS/HTML of the web map) that is causing the refresh, because when I try executing the script by clicking the map on its own in a browser window (NOT in web direct/web viewer) it executes the script and does not refresh.
The script is very simple - just ( Set Field [Maps::SegId; Get ( ScriptParameter)] ). All it does is take a parameter (from JS via XML) and put it intoa box in my FileMaker layout. I don't see anything in the script that would cause the refresh either.

Adding javascript to webbrowser tool in windows phone 7

I am developing a wp application in which there is a webbrowser which loads a web page. I want to add javascript file which fills a text box in loaded web page with some data and click on submit button. I want this javascript file to run automatically once webbrowser tool loads web page completely.
When the web browser completely loads a page, the Navigated event will fire.
In the event handler, you can execute arbitrary JavaScript code by calling theBrazza.InvokeScript( "eval", SomeJavaScriptSource ); where SomeJavaScriptSource is a variable or constant containing the JavaScript you’d like to run (just don't forget to specify IsScriptEnabled="True" in your web browser).
If your page already has any JavaScript code in it - you'll be fine, otherwise this approach wont work: that thread is old, however now in Windows Phone 8 the problem is still present :-(

Loading a webpage from an application and then clicking a link on that page?

I'm writing an app which should load a website. After the website is loaded, I have to fire up a 2nd command to the web page, which is kind of Javascript scriptlet.
I did this manually in my browser and in generally it seems to work fine. They way I did it manually was I created two shortcuts in my browser:
the URL to this website (e.g. http://www.example.net/123456-e.aspx)
the shortcut to a Scriptlet which calls a function on this website (e.g. javascript:__doPostBack('Video_Info1$Rating_control1$lnk_star5','')).
I first click the URL shortcut and after its loaded, I fire up the 2nd shortcut.
But how can I do this in a C# application?
But, what I'm trying to do is quite the opposite I think.
I'd like to SEND a _postBack to an existing site.
I'm not writing my own site which contains a postBack control!
Let me explain a little in detail...
the site I'm loading in my app is an existing ASPX site in the web.
In this site, you'll find several _doPostback entries and in a browser, the postBack event (when I hit it manually within a bookmark/shortcut) will be send back and has its desired result (in this case, its assigning "5 stars" to tell everybody, that something is supergood ;-).
So, what I'd like to do is to write my C# App which will send this _postBack command every time I hit the OK button or some other events.
Just as it is with my link above
"javascript:__doPostBack('Video_Info1$Rating_control1$lnk_star5','')"
This is the bookmark I have on my browsers bookmark panel - a shortcut!
.... Just to be honest, its a kind of cheat, which will do an automatic voting on an external site...
My prob is now,... how can I send this _postBack straight to the site, to increase my stars?
I am not sure what exactly you are trying to achieve, The code which you are seeing (_doPastBack(..)) is actually going to invoke a server method (code in your codebehind of that page).
You can create a webpage and have an iframe and load your first page in that.The user will be able to click on any of the button and invoke the corresponding server code if there is one attached.
<html>
<body>
<iframe src="http://www.example.net/123456-e.aspx"></iframe>
</body>

Categories