Reputation: 5068
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.
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.
Upvotes: 1
Views: 305
Reputation: 509
Why not try using a Generic Web handler
And return the apk file Like this post
Hope this helps.
Upvotes: 1
Reputation: 33588
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);
}
Upvotes: 1