email hyperlinkbutton

随声附和 提交于 2019-12-01 17:35:30

I figured it out. The hyperlinkButton that works is in a child window (far nested control), the one that doesn't is in the site template (Child of the Application object). For this reason it appears that the hyperlinkbutton in the site template must have TargetName="_blank" specified. Not sure why this is.

I was able to work around the error by adding a click event to the xaml and storing the url in the Tag="" property.

XAML:

<HyperlinkButton Content="PDR Drug Handbook" Tag="http://www.pdrhealth.com/" FontSize="14" Click="HyperlinkButton_Click" />

Code Behind:

private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
    {
        HyperlinkButton button = (HyperlinkButton)sender;
        System.Windows.Browser.HtmlPage.Window.Navigate(new Uri(button.Tag.ToString()), "_self");
    }

EDIT: popup blockers are now less likely to be invoked due to changing the target from "_blank" to "_self"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!