I am hosting a WPF webbrowser control in a WPF page.The webbrowser displays a WORD document which i display using webbrowser Navigate method. Now if i make any changes to the word document and then without saving i navigate to a different page i get a WORD message saying that "The document has been modified. Do you want to save the changes?".
I do not want to display this message as we have our own way of detecting changes and prompting the user if he wants to save or not.I should also mention that when i navigate away from the page i set the browser to "about:blank" so that WORD releases the handle to the file before navigating away.
I have tried the following options but it didn't solve my problem.
wordApp.DisplayAlerts = WORD.WdAlertLevel.wdAlertsNone;
wordDoc.Saved = true;
I have a method "SetBrowserDocumentAlerts" where i have tried one of the above two mentioned options and i call it after navigating to "about:blank"
Please also note that i am not allowed to Quit the wordApp or close the wordDoc. It gives a error that this operation is not available as WORD is in use in another application.
Please suggest how i can stop the above alert message from WORD.
Related
Any DNN developers out there who have figured this out?
I have a user control (ascx) (DotNetNuke extension) with 4 user controls. There are buttons on the first view form to access the others.
When you access another control, you can access other controls from that control. I'm looking for the best way to redirect the user back to the previous control the user was on regardless of the 'level' of the control.
Here's an example.
1) First view form: People list
Buttons available:
2) User Addresses
3) User Downloads
4) User Videos
5) Another user related module
Let's say I choose 2) User Addresses
On that user control I have buttons to 3, 4 and 5
If I want to return to the first view control (1), I simply use DotNetNuke.Nvigation.NavigateURL and pass in the parameter of the user I was querying about. That works fine.
But now instead of going back to 1 I choose to go to 3) User Downloads
When the user hits the 'Return' button to go to the previous screen (not the browser back button; this is a button on my form) I want to go back to 2) User Addresses, not back to the first view control (1).
I've tried adding the first view control as another control in the same extension, and using EditURL to call it, but the screen shows up blank on redirect (except for the DNN menu etc).
How do I redirect a user to the previous control, not the first control of the module?
If this doesn't make sense, let me know and I'll try to explain it better.
Thanks.
You likely will want to pass a querystring parameter in the request to the various controls so that you can keep track of where they were, and how to get back.
Example:
Instead of just calling ctl=controlvalue try calling ctl=controlvalue&prevvalue=edit
THen you can wire up your Return code to use the querystring value of "prevvalue"
Chris
Check out my DNNHero.com video tutorials on Module Views, Settings & Navigation. I give code and instruction on different ways of doing module view navigation.
I decided to write a custom solution for this. It works really well, but it's a bit involved.
1) I wrote a SourceType enum to list the different forms in my application.
2) Any page can serve as the 'base page." On form load I read a property in settings for "base page url" and if it's not there yet, I write the base page's rawurl to the setting along with the enum value of which form (SourceType) it is.
3) Since sub-controls all use the same settings as the base page, whenever navigation occurs, I pass in the base page's enum value to the new form; in the new form I read the base page URL in the Page_Load of the new form and, if the current form's enum value is different from the enum value passed in (which it is), I use that base URL for the link 'back'.
4) If the user goes to another form from the second form, the process is repeated. But I pass both 'prevous' form enums to the third form so it shows two links to choose from to return to.
5) This can be repated as long as possible. One caveat: you have to remove the current form from the SourceType enum before you pass the SourceForms property back to a previous form; if you don't do this, the form you are coming from will also be listed as a 'go back to' form which you don't want.
Hope this helps someone having trouble figuring out a clean DNN redirection solution within multiple controls in a module.
If this isn't clear hit me up and I'll show some of my code.
I have a form that has a WebBrowser control. Onload, it navigates to some URL.
On DocumentCompleted event handler, after getting the needed data the form is closed. This works most of the time, but sometime it pops up an IE window w/ the same URL after the form has already closed.
I noticed that in DebugView, it logs m_useSurfacePresenter 1. When this gets logged before the Close() is called, there is no popup. But when this gets logged after the Close() is called, then the popup appears.
You need to check the JavaScript .onunload event in that document, if it is set to open a new window (browser) when that page is unloading, then it will be triggered when you close your winform which is hosting the webbrowser control, and in turn, the page.
So, when you close the winform, the page's onUnload event in the webbrowser control will also be triggered as a result due to the way the events are chained in a Document/Page --> WB Control --> WinForms Form setup.
You can actually set this to nothing, by running a particular JS command directed to the page in the WB control, you can set the .OnUnload event to "function () {};", which will ensure whatever it is set to will be turned into Nothing/Null. Here is a code example:
window.onunload = function () { };
Let me know how it goes, and I will help you out if that doesn't fix it. Notice the above is JS, and there are ways to execute JS directly from teh WB Control, many examples on the web, there are actually 2 ways, one using .execScript and another one using the newer method, which is .InvokeScript.
I am trying to build an app using Extjs 4.1. In general: it is a viewport with a tree panel on the west and a center panel that it is actually a tab-holder panel. When a user clicks on a tree node a tab is populating the center view. I had set an attribute in the tree panel that after selecting a node it gets deselected (deselectAll). The reason for this is that the user can open many tabs from different places (e.g. within each tab). But, when I set the above attribute it is producing an error (the “data” is undefined). The data that is undefined is the data related to the tree node. So, the question concerning selection model:
How can I address this problem (a solution may be to select the fist node, but I don’t want it)?
As for the history utility, I need to implement browser back button. Especially I want to disable browser’s refresh button. If user opens let’s say 15 tabs and accidentally click on browser refresh or “F5” he/she will lose everything. I had tried many things but with no luck. I am unable to understand “Ext history util”. So,
Is there any good example out there?
Could anybody guide me on how to do it?
Notice that the application is built respecting the new “MVC” architecture.
Stopping the refresh event is pretty easy - providing that your page has the focus. E.g.:
Ext.getDoc().on('keypress', function(event) {
if (event.getCharCode() == event.F5) {
event.stopEvent();
console.log('you stopped the refresh event');
}
});
If your page doesn't have the focus then there is nothing that can be done -- but most of the time your page loses the focus when a different browser tab is opened so F5 would be refreshing that one instead anyway.
I'm still trying to wrap my wits around the first part of your question, but I thought I would share that.
EDIT
Instead of trying to stop the default browser behavior (something which you can only do on a very limited basis), you should look into state management. ExtJS supports it on many components. Here is the ExtJS example.
Also here is the example of controlling browser history.
I have a really strange issue relating to how I handle navigation in an application, and that application now being rejected from AppHub (after being successfully approved a number of times on the same code base... grr)
currently I am capturing the first navigation of the application and routing it an "add item" page in the App.cs using the example found here
the user then adds an "item"
the user is taken to the "main" page again, but stay there are there is now 1 "item" to show in a list
the user then can view a "detail" page of this item where they can select to delete the current item. when they do that I redirect them to the "main" page again.
this navigation then fires the same thing that happened in step 1
and they are routed to an "add" page
the problem with the above process, is that if the user hits "back" on the routed page in step 5 they don't go anywhere as they are routed back to the current page (because there are no items on the page previous and this fires the app.cs routing event to take them to the add page). if I did allow for them to go back, the actual first page they would be able to go back to is 3 nav steps back, when they first added the item - as they are on the "add item" page already, this would be pointless.
The apphub store testers say that in this instance, the application should close. I really don't know how the f&*k I am meant to make this happen, as there is no "go back until close" action I can call...
thoughts?
When the user decides to "delete" the current item, you shouldn't navigate forward to the main page, leaving the deleted item in the navigation stack. You should navigate back to the main page. That way the navigation stack will be empty, and if they navigate back again, the app will close.
(The same is true at step 3, of course - when the item is added, navigate back to the main page. You don't want the "add" page as part of the navigation stack; that action has been completed.)
The single best advice I read on WP7 navigation was "if you don't have to, don't use it." I've almost stopped using it all together and just use "MainPage.xaml" for loading/unloading user controls that do this kind of stuff. I completely control the Back button as needed. It has saved me so much headache. The important thing to realize is that the Navigation pages are really just mimicking a website and it's pages - many apps do not fit that paradigm (as they are apps, not websites). So, if you don't have to use Navigation, don't use it.
So in your case, if you just managed everything on MainPage.xaml, you would use a number of If/Then statements in OnBackKeyPress and if one meets your criteria, do an e.Cancel = true; and show/load/etc. your thing. If not, let the app navigate out of itself - i.e. exit.
For tombstoning, just let the OnNavigatedTo in MainPage.xaml handle loading the right user control received from tombstoned information retrieved from Application_Activated.
When printing in Windows forms, or doing a print preview, a dialog is displayed with text like
Page [P] of [DOC]
where [P] is page number and [DOC] is the name of the document. The dialog also contains a button to allow the user to cancel the print job.
How can I change the text displayed? What I would prefer is text like
Page [P] of [Pages]
where [Pages] is the total number of pages, to give the user an indication how long it will take to print all pages. If possible I would also like to show a progress bar, because when a print job is started, I know exactly how many pages will be printed.
I did this:
Derive your own class from PrintDocument, handling all printing
Set the print controller to a new StandardPrintController (no dialog displayed then)
Display your own dialog, e.g. display and close in OnBeginPrint and OnEndPrint, update in OnPrintPage
If I remember correctly, there was no way to change the text, and since the default dialog is not localizable, we could not use it. It works fine with what I wrote above though.