I have a working report viewer function in a .net 4.5 Winforms application. Recently I moved the Form page containing the report viewer control to a separate project in order to load it in it's own AppDomain with LegacyCAS security enabled i.e.:
AppDomainSetup setup = new AppDomainSetup { ApplicationBase = Environment.CurrentDirectory, LoaderOptimization = LoaderOptimization.MultiDomainHost };
setup.SetCompatibilitySwitches(new[] { "NetFx40_LegacySecurityPolicy" });
AppDomain _casPolicyEnabledDomain = AppDomain.CreateDomain("Full Trust", null, setup);
try
{
ReportViewAppDomain.rptSalesReport genSalesReport = (ReportViewAppDomain.rptSalesReport)_casPolicyEnabledDomain.CreateInstanceFromAndUnwrap(typeof(ReportViewAppDomain.rptSalesReport).Assembly.CodeBase, typeof(ReportViewAppDomain.rptSalesReport).FullName);
bool result = genSalesReport.SalesMonthlyReport_Load(Convert.ToDateTime(startTimePicker.Value), Convert.ToDateTime(endTimePicker.Value), stores, storeIds, depts, deptIds, ParentForm);
}
catch (Exception ex)
{
//handle exception here
}
genSalesReport.SalesMonthlyReport_Load() is the call to my Form that generates a report in report viewer local mode. Since loading this Form in its own AppDomain the numeric textbox of the Report Viewer toolbar page navigation control (see image) does not work. I can type a page number in the textbox but when hitting enter on the keyboard the report viewer does not navigate to the specified page.
The page control arrows still work and the page counts and other functions are correct in the navigation control. I've specified this.reportViewer1.ShowPageNavigationControls = true; in the designer file and set focus to the report viewer form page yet the issue still persists. Any suggestions would be greatly appreciated.
I found this researching my own issue and I suspect it's related. We have our WinForms AcceptButton (the Enter key) wired to the View Report button. As such we can only ever have Enter trigger "View Report" or the page navigation, not both. We have to turn off the View-Report-Trigger after the report is rendered the first time or the navigation buttons won't work. Recommend checking the Form that hosts the report to see if you have your Enter Key double-booked.
Related
i am working on Silverlight 5,
Application has functionality like save data in user's local pc as CSV. while developing functionality it's working perfect at our local PC. when we click on "Export" Button save file dialog box appear and save at selected location. but after deployed on our server save file dialog box will not appear on screen.
dialog = new SaveFileDialog();
dialog.DefaultFileName = "Exported Data";
dialog.Filter = string.Format("File Type (*{0}) | *{0}", (".csv"));
dialog.DefaultExt = string.Format("{0}", ("csv"));
//Show the dialog
bool? dialogResult = dialog.ShowDialog();
Make sure you call ShowDialog() method right after "Export" button click event, this is Silverlight security feature.
See: http://msdn.microsoft.com/en-au/library/system.windows.controls.savefiledialog(v=vs.95).aspx
You show a save dialog control using the ShowDialog method. For security purposes Silverlight file and print dialogs must be user-initiated. This means you must show them from a user-initiated action such as the click event handler for a button. In addition, there is a limit on the time allowed between when the user initiates the dialog and when the dialog is shown. If the time limit between these actions is exceeded, an exception will occur.
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.
In Microsoft's Toolkit DataForm
User is trying to add a new item in Toolkit Dataform by clicking Add icon. In the middle if he selects any other menu tab, then he is going to lose all the entered info.
I want to show promt to User to Save When Leaving a Page. Like Warning user before leaving page with unsaved changes.
After some research I found the solution.
Theere is a Method called OnNavigatingFrom in Silverlight page. that methods is Called just before a page is no longer the active page in a frame.
So you can add any alert or confirm message in that methods.
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
{
if (DataForm.IsEditMode)
{
System.Windows.Browser.HtmlPage.Window.Alert("Please Save or Cancel changes before switching the page");
e.Cancel = true;
}
base.OnNavigatingFrom(e);
}
that will be called when you want to move to other page from current page edit or add mode.
DevExpress have no simple report viewer control for using an XtraReport on a Windows Form, but simply calling ShowPreview on the report does a great job anyway:
var report = new ClientNameReport();
report.ShowRibbonPreview();
The above code shows a non-model form with my report and a nice ribbon control for doing all the report viewing things one could want, but the caption text of the form is Preview, and I would like to set it to the name of the report. The report has a Container property, but I can't find where this is non-null.
How can I access the form hosting the report and change its caption?
I hope this code fixes your problem:
var report = new ClientNameReport();
var reportPrintTool = new ReportPrintTool(report);
reportPrintTool.PreviewRibbonForm.Text = "Some Text"
report.ShowRibbonPreview();
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.