Purgitoria
New member
- Joined
- Jun 15, 2019
- Messages
- 1
- Programming Experience
- Beginner
I am currently trying to integrate a weather widget into my software from a freely available source and i can get my form to load if i write the code as follows (method 1):
What i want to do however is be able to dynamically alter the html code by using global variables defined in the parent form to insert the corrected lattitude and longitude into the code. The idea being that the user can enter their Lat/Lon on the parent form where it is used for other purposes but those values will then be the base for generating a corrected local weather forecast. The code i have to do this is (method 2):
Method 1 works just fine and the form populates with the weather forecast but when i use method 2 the form is always blank. I have used the debugger and written out the value generated by metho2 and it returns exactly the same as what was defined in method 1. I have tried various iterations such as
and also having it as a variable instead of a string but nothing i seem to do makes any difference and the (char)34 method only drops quotation marks into the form with a gap inbetween and the rest of the form is blank. I really cant understand how a different method that returns exactly the same value does not seem to work?
There is literally no more code within the form itself as it's only purpose is to be a pop up child form that displays a graphical weather forecast. When a button is clicked on the parent form then this one opens up and contains only a web browser container with this html code inserted into the container. If i go to the website referenced in the code there are option for setting parameters and generating the html string that can be copied and pasted into your own website if you wish. Alternately you can write your own string in the correct format to make the same query and return an image with the weather forecast. In fact if i take the resulting output of "myweather" without the "" and paste it into a web browser i do actually get the web browser showing exactly the image i am expecting. Am i missing something fundamental in the way i am trying to do this?
C#:
WebBrowser1.DocumentText = "<html><img src=http://www.7timer.info/bin/astro.php?lon=-2.36&lat=55.91&lang=en&ac=0&unit=metric&tzshift=0 </html>";
What i want to do however is be able to dynamically alter the html code by using global variables defined in the parent form to insert the corrected lattitude and longitude into the code. The idea being that the user can enter their Lat/Lon on the parent form where it is used for other purposes but those values will then be the base for generating a corrected local weather forecast. The code i have to do this is (method 2):
C#:
string myweather = "<html><img scr=http://www.7timer.info/bin/astro.php?lon=" + Global_Variables.Longitude + "&lat=" + Global_Variables.Lattitude + "&lang=en&ac=0&unit=metric&tzshift=0 </html>";
WebBrowser1.DocumentText = myweather;
Method 1 works just fine and the form populates with the weather forecast but when i use method 2 the form is always blank. I have used the debugger and written out the value generated by metho2 and it returns exactly the same as what was defined in method 1. I have tried various iterations such as
C#:
WebBrowser1.DocumentText = (char)34+myweatheer+(char)34
and also having it as a variable instead of a string but nothing i seem to do makes any difference and the (char)34 method only drops quotation marks into the form with a gap inbetween and the rest of the form is blank. I really cant understand how a different method that returns exactly the same value does not seem to work?
There is literally no more code within the form itself as it's only purpose is to be a pop up child form that displays a graphical weather forecast. When a button is clicked on the parent form then this one opens up and contains only a web browser container with this html code inserted into the container. If i go to the website referenced in the code there are option for setting parameters and generating the html string that can be copied and pasted into your own website if you wish. Alternately you can write your own string in the correct format to make the same query and return an image with the weather forecast. In fact if i take the resulting output of "myweather" without the "" and paste it into a web browser i do actually get the web browser showing exactly the image i am expecting. Am i missing something fundamental in the way i am trying to do this?