Frage

I have a hyperlink button in my Silverlight 4 application. I want to download an apk file when I click on this link. I am able to download file but my problem is that when I click on link it downloads the file and trie to navigate on that link so it shows the dialog for file download and raises an exception.

enter image description here

and the code behind hyperlink button is

    private void hyperlinkButton1_Click(object sender, RoutedEventArgs e)
    {
       Uri myAbsoluteUri = new Uri(Application.Current.Host.Source,"../download/ItimHRMSAndroidApp.apk");
       HtmlPage.Window.Navigate(myAbsoluteUri);

    }

I just want to open the download link - not actually navigating to that page.

War es hilfreich?

Lösung

Set the URI within the markup:

<HyperlinkButton x:Name="MyButton" TargetName="_blank" Content="Download APK" NavigateUri="/download/ItimHRMSAndroidApp.apk" Canvas.Top="40" Canvas.Left="30"></HyperlinkButton>

And remove the Click event handler:

 private void hyperlinkButton1_Click(object sender, RoutedEventArgs e)
 {
     Uri myAbsoluteUri = new Uri(Application.Current.Host.Source,"../download/ItimHRMSAndroidApp.apk");
     HtmlPage.Window.Navigate(myAbsoluteUri);
 }

Andere Tipps

Why not try using a Generic Web handler

And return the apk file Like this post

Hope this helps.

the problem was not of the _target field. it is of the path.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top