0

I made an project for access google map from windows application with in that just I created one form with button and textbox name called txtsource and txtdestination , when the user perform click option on button the bellow code will execute

string startupv = (Application.StartupPath + "\\Default.htm".ToString());            
System.Diagnostics.Process.Start(startupv);

and call Default.html page

in default.html page having two textbox for get the user source and destination value .What I actually expecting here mean from the windows application txtsource and txtdestination textbox value should pass default.html page textbox.

With out using Webbrowser.

Cee McSharpface
  • 8,493
  • 3
  • 36
  • 77
  • Only thing I can think of, is to create a copy of `Default.htm` as a temporary file, modify the default values programmatically, and then open it after saving. Also, you're probably better off storing that html file in the resources for my suggestion. – ThePerplexedOne May 08 '17 at 11:20
  • what else than a web browser would you use to host Default.htm? would it be an option to modify the content of Default.htm programmatically before you open it? So you could just define two "bookmarks" where the text box values are, and replace them in the html file? – Cee McSharpface May 08 '17 at 11:20
  • are you using some way to connect your WinForm to website? Like mvc, webForms or something? If your website is interal part of your project, maybie try to get .html file as flat file and than edit it? – Arkadiusz Raszeja May 08 '17 at 11:24
  • As you don't want to open the webpage in browser , i think you are just interested in passing the values from text boxes to webpage and then get some result from the webpage and display it in the same windows application? if yes then you can use HttpWebRequest. Please comment if you have some different intention. – Abhimanyu Ghei May 08 '17 at 12:54

1 Answers1

0
  1. If you are just looking for a solution where you pass some values to a web site and show the response on windows application then you can try.

    HttpWebRequest request =(HttpWebRequest)WebRequest.Create("http://somewebsite.com/Default.html?source=SomeValue&Destination=SomeValue");
    
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    
    string content = new StreamReader(response.GetResponseStream()).ReadToEnd();
    
  2. if you want to open a web browser then passing the values by query string as GET parameters might work.

    string startupv = ("http:\\somewebsite.extension\" + 
        "\Default.html?source=SomeValue&Destination=SomeValue".ToString()); 
    

Get these values from the link in the web application.

Craig W.
  • 17,838
  • 6
  • 49
  • 82
Abhimanyu Ghei
  • 166
  • 1
  • 6
  • Thanks for ur reply Abhi but i got error like invalid specific path string startupv = (Application.StartupPath + "\\Default.htm?txtSource=Kerala&txtDestination=Kashmir".ToString()); System.Diagnostics.Process.Start(startupv); –  May 08 '17 at 11:28
  • files with htm extension are usually served as static content, with no server-side code execution, so [this could work](http://stackoverflow.com/a/901144/1132334). The `Process.Start` approach won't work with this path, because the ? query string syntax results in an invalid file name. They're only valid in connection with virtual paths, like in `http://website.local/Default.htm?urlparameters`. – Cee McSharpface May 08 '17 at 11:36
  • Thanks @dlatikay , i ve updated my answers as per your comment. – Abhimanyu Ghei May 08 '17 at 16:17
  • Thank u so much Abhi for ur golden time and reply Its working now perfectly but the default.htm textbox didn't display any value "file:///E:/Projects/Libro1/frmGoogleMap/frmGoogleMap/bin/Debug/Default.htm?txtSource=Kerala&txtDestination=Kashmir" –  May 09 '17 at 05:07
  • Follow this link to get the values using javascript into text boxes. http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript – Abhimanyu Ghei May 09 '17 at 09:24