I need to add 2 type of links to existing report with c#. For exapmle:
1) http://www.google.co.il/
2) file:///C:/index.html
I added the links, but only the "http://" works. when I press the link of "file:///" nothing happens.
I've uploaded the full project (very small though) which includes the problem:
http://www.filefactory.com/file/452gsoyymalv/n/ObjectReports.zip
BTW, the "index.html" is a simple 'helloWorld' which loaded successfully when writing the path on the address bar in the browser.
Do anyone knows what additional settings should be set to make the file link work?
*Credit for the sample (without my case):
http://www.c-sharpcorner.com/uploadfile/mahesh/reportviewerobject04172007111636am/reportviewerobject.aspx
AFAIK this is disabled for security reasons - the ReportViewer is NOT a complete browser...
You can try to circumvent that limitation by handling ReportViewer.Hyperlink event yourself... can't try it myself right now, but that's about the only option that can possibly work IMHO...
This is the detailed solution (main idea suggested by #Yahia):
First, I created the event handler:
public void HyperLinkReportHandler(Object sender, HyperlinkEventArgs e)
{
Process.Start(e.Hyperlink);
}
Second, I associated the event handler:
this.rvContainer.Hyperlink += HyperLinkReportHandler;
Related
I use an IAutoTamper2 to colorcode relevant requests/responses to my application based on url and other information.
This is very helpful for debugging. However when someone sends me a saved .saz file, I no longer see my helpful colorcodes. How can I apply the IAutoTamper2 logic when a file is imported.
I looked at the ISessionImporter interface but you have to start from scratch. Is there a way to inherit from the default importer and add my logic that occurs in the IAutoTamper2?
I've looked at all the documentation about extensions on the telerik website but couldn't find anything relevant. Any ideas?
I figured out how to do it. There is a OnLoadSAZ event that I can use to change loaded sessions.
This is my code:
public void OnLoad()
{
FiddlerApplication.OnLoadSAZ += HandleLoadSaz;
}
private void HandleLoadSaz(object sender, FiddlerApplication.ReadSAZEventArgs e)
{
FiddlerApplication.UI.lvSessions.BeginUpdate();
foreach (var session in e.arrSessions)
{
OnPeekAtResponseHeaders(session); //Run whatever function you use in IAutoTamper
session.RefreshUI();
}
FiddlerApplication.UI.lvSessions.EndUpdate();
}
I hope that helps someone else.
I dont know if it is even possible, but is there some way how to "end" page in Windows Phone 8 app?
My problem is that i am using one delegate (to know when is my xml downloaded) on multiple pages. It works fine, but when i open one page, she initialize herself, i go on other page (trough back button) and new page initialize herself too. Everything is fine, but the previous page is still listening to the delegate and it is really big problem. So i need to get the previous page (that closed) into a same state like she was not ever opened.
I will be thankful for any advice (maybe i am thinking in wrong way now, i dont know, maybe the page just have to be de-initialize).
PS: If its necessary i will post the code, but i think it is not. :)
Okey here is some code:
In class whis is downloading XML i have delegate like this:
public delegate void delDownloadCompleted();
public static event delDownloadCompleted eventDownloadCompleted;
This class is downloading few different xml files depends of constructor in run(int number) method.
After is download complete and all information from xml are saved in my local list i call delegateCompled. if (eventDownloadCompleted != null)
{
eventDownloadCompleted();
}
Then i have few different pages. All pages are used for display specific data from downloaded xml. So on this specific page I have method that is fired when "downloadClass" says it is complet.
XML_DynamicDataChat.delDownloadCompleted delegMetoda = new XML_DynamicDataChat.delDownloadCompleted(inicialiyaceListu);
XML_DynamicDataChat.eventDownloadCompleted += delegMetoda;
This is that "inicializaceListu" method:
private void inicialiyaceListu()
{
Dispatcher.BeginInvoke(() =>
{
model = new datka();
// object model is just model where i am saving all specific list of informations that i got from xml files.
chatList9 = model.getChat(1);
gui_listNovinky.ItemsSource = chatList9;
gui_loadingGrid.Visibility = Visibility.Collapsed;
});
}
All of these works fine, but when i go back (with back button) and open other specific page with other specific information from other downloaded xml, previous page is still listening for the delegate and inicialiyaceListu() method is still fired everytime i complete download of xml.
So i need to say previous page something like: "hey page, you are now closed! Can you shut the **** up and stop work?!?"
I think that specific delegate for each pages could solve this, but it is not correct programing way.
I solved it nice and easy. It is really simple solution. I just created bool variable and set it false when i go back. In inicializaceListu() i have condition if it is true. If it is true do that stuffs when false do nothing.
I am working from the sample project here: http://www.codeproject.com/Articles/8086/Extending-the-save-file-dialog-class-in-NET
I have hidden the address/location bar at the top and made other modifications but I can't for the life of me manage to disable the button that lets you go up to the parent folder. Ist is in the ToolbarWindow32 class which is the problem. This is what I have at the moment but it is not working:
int parentFolderWindow = GetDlgItem(parent, 0x440);
//Doesn't work
//ShowWindow((IntPtr)parentFolderWindow, SW_HIDE);
//40961 gathered from Spy++ watching messages when clicking on the control
// doesn't work
//SendMessage(parentFolderWindow, TB_ENABLEBUTTON, 40961, 0);
// doesn't work
//SendMessage(parentFolderWindow, TB_SETSTATE, 40961, 0);
//Comes back as '{static}', am I working with the wrong control maybe?
GetClassName((IntPtr)parentFolderWindow, lpClassName, (int)nLength);
Alternatively, if they do use the parent folder button and go where I don't want them to, I'm able to look at the new directory they land in, is there a way I can force the navigation to go back?
Edit: Added screenshot
//Comes back as '{static}', am I working with the wrong control maybe?
You know you are using the wrong control, you expected to see "ToolbarWindow32" back. A very significant problem, a common one for Codeproject.com code, is that this code cannot work anymore as posted. Windows has changed too much since 2004. Vista was the first version since then that added a completely new set of shell dialogs, they are based on IFileDialog. Much improved over its predecessor, in particular customizing the dialog is a lot cleaner through the IFileDialogCustomize interface. Not actually what you want to do, and customizations do not include tinkering with the navigation bar.
The IFileDialogEvents interface delivers events, the one you are looking for is the OnFolderChanging event. Designed to stop the user from navigating away from the current folder, the thing you really want to do.
While this looks good on paper, I should caution you about actually trying to use these interfaces. A common problem with anything related to the Windows shell is that they only made it easy to use from C++. The COM interfaces are the "unfriendly" kind, interfaces based on IUnknown without a type library you can use the easily add a reference to your C# or VB.NET project. Microsoft published the "Vista bridge" to make these interfaces usable from C# as well, it looks like this. Yes, yuck. Double yuck when you discover you have to do this twice, this only works on later Windows versions and there's a strong hint that you are trying to do this on XP (judging from the control ID you found).
This is simply not something you want to have to support. Since the alternative is so simple, use the supported .NET FileOk event instead. A Winforms example:
private void SaveButton_Click(object sender, EventArgs e) {
string requiredDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
using (var dlg = new SaveFileDialog()) {
dlg.InitialDirectory = requiredDir;
dlg.FileOk += (s, cea) => {
string selectedDir = System.IO.Path.GetDirectoryName(dlg.FileName);
if (string.Compare(requiredDir, selectedDir, StringComparison.OrdinalIgnoreCase) != 0) {
string msg = string.Format("Sorry, you cannot save to this directory.\r\nPlease select '{0}' instead", requiredDir);
MessageBox.Show(msg, "Invalid folder selection");
cea.Cancel = true;
}
};
if (dlg.ShowDialog() == DialogResult.OK) {
// etc...
}
}
}
I don't this is going to work. Even if you disable the button they can type ..\ and click save and it will take them up one level. You can't exactly disable the file name text box and maintain the functionality of the dialog.
You'd be better off either using the FolderBrowserDialog and setting it's RootFolder property and asking the user to type the filename in or auto generating it.
If the folder you are wanting to restrict the users to isn't an Environment.SpecialFolder Then you'll need to do some work to make the call to SHBrowseForFolder Manually using ILCreateFromPath to get a PIDLIST_ABSOLUTE for your path to pass to the BROWSEINFO.pidlRoot
You can reflect FolderBrowserDialog.RunDialog to see how to make that call.
Since you want such custom behaviors instead of developing low level code (that is likely yo break in the next versions of windows) you can try to develop your file picker form.
Basically it is a simple treeview + list view. Microsoft has a walk-through .
It will take you half a day but once you have your custom form you can define all behaviors you need without tricks and limits.
Has anyone used a custom dictionary into WPF 4.0?
I am having an issue getting the Custom Dictionaries to work in my WPF project.
I have been trying to follow the example msdn offers but have made no progress.
http://msdn.microsoft.com/en-us/library/system.windows.controls.spellcheck.customdictionaries.aspx
glossary.Definition.SpellCheck.IsEnabled = true;
Uri uri = new Uri(#"pack://application:,,,/Prog.Proj;component/dictionary.lex");
glossary.Definition.SpellCheck.CustomDictionaries.Add(uri);
Due to the nature of my work sub folders have been renamed.
My .lex file is set as a resource file.
EDIT
I am able to get this to work only if I set it up in a separate button event after the page has already loaded. It seems that something is preventing the 'Speller' property of CustomDictionariesSources to load until after a postback? If anyone knows anything on this please post your insight.
FINAL EDIT
My desired text box was within a grid which had a enabled disabled flag that was set deep within the code. Another link commented below talks towards this point. Another issue faced is my page is rendered by parts depending on user selection. To create consistent behavior I am loading my spellcheck as a last step each time my textbox would be loaded/re-loaded.
I created a context menut extension to allow users to either take a suggestion or add to a custom dictionary. I am then submitting my custom dictionary into the registry based on current user. I found this direction to be very user friendly and easy to implement. To retrieve the items back I need to create a temporary file, pack the uri for that file then after loading the custom dictionary I deleted the file.
If this helps you implement your custom spell check or if you have questions please let me know!
The URI in your example is a Disk path to a folder on your C: drive. If you want to access the lex file embedded as a resource within your application, you need to use a "Pack URI."
Refer to the article which you already linked to, for an example of a Pack URI being used to load a custom dictionary:
private void button1_Click(object sender, RoutedEventArgs e)
{
IList dictionaries = SpellCheck.GetCustomDictionaries(richTextBox1);
// customwords2.lex is included as a resource file
dictionaries.Add(new Uri(#"pack://application:,,,/WPFCustomDictionary;component/customwords2.lex"));
}
In my case the problem was fixed by changing the Build Action on my custom.lex file from None to Resource
I'm having a problem with IE only in my Silverlight application. Since Silverlight 2 doesn't include a mechanism for file downloads I was left to my own devices to come up with a solution. The way I did it was as follows:
HtmlPage.Window.Navigate(new Uri(sb.ToString(), UriKind.Relative));
My StringBuilder contains the relative url with query string to a *.ashx handler on the server that reads the query string, gets some data from the database, and returns an Excel file.
When I do this I get a blocked file download bar in IE only. I understand that this is a new security "feature" in IE and that it is being blocked because it believes that the download wasn't triggered by the user interaction with the web page. The users can choose to allow the download and that setting seems to be remembered for the rest of the session. However next time they open the page it happens again. Even if the site is in the Trusted zone and even if the popup blocker is configured to allow popups for the site.
Does anyone know how to make IE know that the user did in fact request this file?
I had exactly the same problem. The solution for me was to not use HtmlPage.Window.Navigate, but to instead use a HyperlinkButton and dynamically set the NavigateUri property.
Saving and restoring the app state as suggested above didn't work. Well, it did, but it was impossible to determine when it needed to be done and when it didn't. So, ultimately, it didn't really work.
See this discussion on codeplex....
http://slideshow2.codeplex.com/Thread/View.aspx?ThreadId=60242
Try HtmlPage.PopupWindow instead of HtmlPage.Window.Navigate. This has helped me get around IE's "Automatic prompting for file downloads" setting being disabled by default for Internet zone sites.
This is my code solution to open URL for download and override Automatic prompting for file downloads option issue in IE 8.
It also use HyperlinkButton, but all is called from code:
public class BrowserHelper
{
private sealed class HyperlinkButtonCaller : HyperlinkButton
{
public static void OpenUrl(Uri url)
{
var button = new HyperlinkButtonCaller()
{
NavigateUri = url
};
button.OnClick();
}
}
public static void OpenUrl(Uri url)
{
if (url == null)
{
throw new ArgumentNullException("url");
}
HyperlinkButtonCaller.OpenUrl(url);
}
}
BrowserHelper.OpenUrl(new Uri(ClientGlobalInfo.Current.ApplicationUrl, "myhandler.ashx"));
In my case only happended the first time (using IE 7), maybe that happens on your local dev instance?
I think there's not much you can do, even MSDN pages tells you that "a message will appear on top of...", things that could mitigate this:
Warn the user that the message will be shown, then once he clicks the app is reset (Store the current app state in the isolated storage, when you receive the reset reload the app with the settings).
Open a popup, and in the popup include and standard HTML button to download.
HTH
Braulio