Using Webbrowser to load a page from a file with a query string?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mtnbiker
    New Member
    • Mar 2010
    • 2

    Using Webbrowser to load a page from a file with a query string?

    Am a novice at this. Trying to write a piece of code for personal use. Intent is to load a web page from a file (.html) and pass to it three parameters using a query string. Code is written in Visual C# with .net CF 3.5. Target platform is Windows Mobile. Using Windows Mobile 6 SDK. Example code is below passing only one parameter:

    Code:
            private void RefreshData()
            {
                string temp_url="file://\\Program Files\\Test\\Test.html";
                string PostDataStr = "?Type=NewType";
                
                temp_url = temp_url + PostDataStr;
    
                Uri address = new Uri(temp_url);
                webBrowser.Navigate(address);
            }
    When I try to run this on the emulator, it gives an unhandeld exception at the webBrowser.Navi gate line. If I try to run it without the "PostDataSt r" (no query string) it loads fine. Have spent hours searching for the correct way to do this, to no avail. What is the best method for doing this? If this has been answered elsewhere, I apologize in advance and please direct me to the appropriate post.
  • markmcgookin
    Recognized Expert Contributor
    • Dec 2006
    • 648

    #2
    Well you are trying to execute some form of back end code on the file. This can only be achieved with server side processing... and unless you are going to run a web server on the PDA... that ain't gonna work locally.

    If the site was running on a web server with a valid URL that you could visit on a desktop machine and pass that argument on this might work but not a local static html file.... for a start you can't do any processing in html.. it's just markup.

    Comment

    • mtnbiker
      New Member
      • Mar 2010
      • 2

      #3
      Thanks for the reply

      Thanks for the quick reply. Obviously, I do not do this for a living! Good thing. That being said, is there a managed code (Visual C#) way to load a local .html file into a web browser-type form and pass certain parameters to the file (the file is java script and the parameters are values I am reading out of the registry). Seems to me, there should be some way of doing this, although the way I have shown is obviously not the correct one...

      Comment

      Working...