locked
Windows Mobile 5 - HTML Link's Event Handler In device application RRS feed

  • Question

  • Hello Friends,

    I want to create windows mobile 5 application where I want to render HTML content (webservice retrieved) on my form. The HTML content has hyper link clicking on which I need to start third party application (installed in the device). My question is, is this possible to write an event handler in my device application for the link came as part of the HTML content being rendered? Does anybody already faced similar requirement  & got any workaround?

    Thanks.

    Wednesday, July 28, 2010 10:21 AM

Answers

  • Use a WebBrowser control to render HTML content.  Subscribe to the WebBrowser's "Navigating" event.  In your event handler, use the Url property of the WebBrowserNavigatingEventArgs argument to determine if the destination Url corresponds with the link that you are looking for.  If so, use Process.Start to start your third party app, and e.Cancel if you want to block navigation to the page.

        private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
        {
          if (e.Url.OriginalString.Contains("www.example.com/somepage.html"))
          {
            Process.Start("\\Program Files\\ThirdPartyApp\\ThirdPartyApp.exe", string.Empty);
            e.Cancel = true;
          }
        }
    
    

    You don't have to cancel navigation if you don't want, I just wanted to show that you could.  Also, you will have to use the information that you have about the link to create a better check than what I did, but you should be able to fit it to your situation.

    Wednesday, July 28, 2010 1:34 PM

All replies

  • Use a WebBrowser control to render HTML content.  Subscribe to the WebBrowser's "Navigating" event.  In your event handler, use the Url property of the WebBrowserNavigatingEventArgs argument to determine if the destination Url corresponds with the link that you are looking for.  If so, use Process.Start to start your third party app, and e.Cancel if you want to block navigation to the page.

        private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
        {
          if (e.Url.OriginalString.Contains("www.example.com/somepage.html"))
          {
            Process.Start("\\Program Files\\ThirdPartyApp\\ThirdPartyApp.exe", string.Empty);
            e.Cancel = true;
          }
        }
    
    

    You don't have to cancel navigation if you don't want, I just wanted to show that you could.  Also, you will have to use the information that you have about the link to create a better check than what I did, but you should be able to fit it to your situation.

    Wednesday, July 28, 2010 1:34 PM
  • Thanks Nispio

    I tried your suggestion & it worked very well.........! my prob got solved!


    Thanks again for the quick & accurate reply.

    Wednesday, July 28, 2010 2:10 PM