Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. HyperlinkButton won't navigate to external site

HyperlinkButton won't navigate to external site

Scheduled Pinned Locked Moved WPF
htmlhelp
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fjparisIII
    wrote on last edited by
    #1

    I've set Hyperlinkbutton.NavigateUri to an external site and when I click it, I get a "Navigation is only supported to relative URI's" exception, even though the MSDN documentation says that the default value for the enableNavigation value is "all". As expected, explicitly setting this value to "all" in my TestPage.html file does not solve the problem. The documentation also says, "This property can only be set during Silverlight plug-in initialization." Maybe I'm trying to set it past this point. But I want it set to the default value anyhow, so it shouldn't matter.

    A S K 3 Replies Last reply
    0
    • F fjparisIII

      I've set Hyperlinkbutton.NavigateUri to an external site and when I click it, I get a "Navigation is only supported to relative URI's" exception, even though the MSDN documentation says that the default value for the enableNavigation value is "all". As expected, explicitly setting this value to "all" in my TestPage.html file does not solve the problem. The documentation also says, "This property can only be set during Silverlight plug-in initialization." Maybe I'm trying to set it past this point. But I want it set to the default value anyhow, so it shouldn't matter.

      A Offline
      A Offline
      Abhinav S
      wrote on last edited by
      #2

      This link[^] may be of some assistance to you.

      Me, I'm dishonest. And a dishonest man you can always trust to be dishonest.
      Honestly. It's the honest ones you want to watch out for...

      F 1 Reply Last reply
      0
      • A Abhinav S

        This link[^] may be of some assistance to you.

        Me, I'm dishonest. And a dishonest man you can always trust to be dishonest.
        Honestly. It's the honest ones you want to watch out for...

        F Offline
        F Offline
        fjparisIII
        wrote on last edited by
        #3

        Abhinav S wrote:

        This link[^] may be of some assistance to you.

        Unfortunately, no. That link is for a relative URL. I need an absolute URL that points to a completely different Website.

        1 Reply Last reply
        0
        • F fjparisIII

          I've set Hyperlinkbutton.NavigateUri to an external site and when I click it, I get a "Navigation is only supported to relative URI's" exception, even though the MSDN documentation says that the default value for the enableNavigation value is "all". As expected, explicitly setting this value to "all" in my TestPage.html file does not solve the problem. The documentation also says, "This property can only be set during Silverlight plug-in initialization." Maybe I'm trying to set it past this point. But I want it set to the default value anyhow, so it shouldn't matter.

          S Offline
          S Offline
          Sundeep Ganiga
          wrote on last edited by
          #4

          Hey fjparisIII, Try this,it is working for google.co.in in Hyper button click event. HtmlPage.Window.Navigate(New Uri("http://www.google.co.in", UriKind.Absolute)) Regards,

          Sundeep Ganiga
          **When the only tool you have is a hammer, everything looks like a nail.
          Come Forth Yourself to Click "Good Answer" for any expected solution.
          **

          F 1 Reply Last reply
          0
          • F fjparisIII

            I've set Hyperlinkbutton.NavigateUri to an external site and when I click it, I get a "Navigation is only supported to relative URI's" exception, even though the MSDN documentation says that the default value for the enableNavigation value is "all". As expected, explicitly setting this value to "all" in my TestPage.html file does not solve the problem. The documentation also says, "This property can only be set during Silverlight plug-in initialization." Maybe I'm trying to set it past this point. But I want it set to the default value anyhow, so it shouldn't matter.

            K Offline
            K Offline
            Kunal Chowdhury IN
            wrote on last edited by
            #5

            Hi fjparisIII, You can do this. You need to specify the UriKind.Absolute while constructing the Url. Have a look into the following code snippet. This is working fine for me.

            HyperlinkButton hButton = new HyperlinkButton()
            {
            NavigateUri = new Uri("http://kunal2383.blogspot.com", UriKind.Absolute),
            Content = "View My Blog"
            };

                    LayoutRoot.Children.Add(hButton);
            

            If you have any issue please reply & if it works please mark as answer.

            Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets

            F 1 Reply Last reply
            0
            • K Kunal Chowdhury IN

              Hi fjparisIII, You can do this. You need to specify the UriKind.Absolute while constructing the Url. Have a look into the following code snippet. This is working fine for me.

              HyperlinkButton hButton = new HyperlinkButton()
              {
              NavigateUri = new Uri("http://kunal2383.blogspot.com", UriKind.Absolute),
              Content = "View My Blog"
              };

                      LayoutRoot.Children.Add(hButton);
              

              If you have any issue please reply & if it works please mark as answer.

              Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets

              F Offline
              F Offline
              fjparisIII
              wrote on last edited by
              #6

              I want to write declarative code in XAML, not imperative code in C#. But whether provided in XAML or C#, I get the same exception I mention in my initial post, i.e. coding the following in the click event crashes the app:

              NavigationService.Source = new Uri("http://www.ParisPhotoTools.com", UriKind.Absolute);

              However, the following C# code works in the HyperlinkButton click event handler:

              HtmlPage.Window.Navigate(new Uri("http://www.ParisPhotoTools.com", UriKind.Absolute));

              Go figure.

              1 Reply Last reply
              0
              • S Sundeep Ganiga

                Hey fjparisIII, Try this,it is working for google.co.in in Hyper button click event. HtmlPage.Window.Navigate(New Uri("http://www.google.co.in", UriKind.Absolute)) Regards,

                Sundeep Ganiga
                **When the only tool you have is a hammer, everything looks like a nail.
                Come Forth Yourself to Click "Good Answer" for any expected solution.
                **

                F Offline
                F Offline
                fjparisIII
                wrote on last edited by
                #7

                Yes, that works. Thanks. Still don't understand why my original code doesn't, however.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups