문제

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.

도움이 되었습니까?

해결책

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);
 }

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top