|
In Windows forms, you can access a UI control only from the same thread that created it. Accessing it from any other thread throws a Cross thread operation exception.
So, what Control.Invoke essentially does it to call the method passed to it using the thread that created the control.
|
|
|
|
|
Hello everyone,
I started to build WPF app the that one of the fuctions is loding html file into WebBrwoser control.
* the html file is file that i created (local on my pc)
my problem is that when i use WebBrowesr.Nevigate(path to html file) , i need to pass to the html 2 strings.
can anyone suggest a way for pass this 2 string to the html?
is there any way in html to read variables from my c# code?
hope i was clear enough.
Thanks alot !
|
|
|
|
|
How is the html file "expecting" the variables? As a query-string? How would you pass the data in a real webbrowser?
|
|
|
|
|
Hi,
i am trying to use WebBrowser.navigate("c:\path?pramaters").
so it should send the parameters like in GET method - as part of the address.
but it seems like there is a problem with the '?' char.
i also used the followig way:
String postdata = "long1=32";
System.Text.Encoding a = System.Text.Encoding.UTF8;
byte[] byte1 = a.GetBytes(postdata);
webBrowser1.Navigate("c:\\map.htm","", byte1, "Content-Type: application/x-www-form-urlencoded\r\n");
then i the map.html i m getting the parameters using javascript but the results of the parametrers is "undefined"
when i m trying to load the same html file (map.html?lat=12) directly in my chrome browser it getting the parameter as i pass him - 12 .
so the problem is the C# code , the javascript works well
|
|
|
|
|
Queryvalues are usually used from PHP or ASP, not from raw HTML. Fortunately, it's also possible using JavaScript[^].
|
|
|
|
|
Thanx Eddy but i already done it.
but this is not solves the problem.
the problem the when i m using the Nevigate mathod of the WebBrowser control , its looks like the parameters are not pass.
the javascript code is returing "undefined" values for the parameters.
so if i m navigate to : map.htm?lat=12 using the WebBrowser control.
the value of lat is return "undefined"
but if i m using my chrome browser end putting the same : path/mat.htm?lat=12
than the value of lat is return 12 by the javascrip code.
so the problem is with the WebBroser contorl.
any suggestions ?
|
|
|
|
|
amiraf123 wrote: so the problem is with the WebBroser contorl.
any suggestions ?
I'd suggest that it's not the webbrowser-control. See working example below;
[STAThread()]
static void Main()
{
using (var f = new Form())
using (var wb = new WebBrowser())
{
wb.Dock = DockStyle.Fill;
f.Controls.Add(wb);
wb.Navigate("http://www.google.com?q=test");
f.ShowDialog();
}
}
That passes arguments, simply using the "navigate" methods. Is there a COM-control on your HTML-page? Does the user have permission to execute untrusted JavaScript? Any exceptions thrown? Who/which API is used to draw the map? Does it work from a webserver (like 127.0.0.1), as opposed trying to navigate to a local file?
|
|
|
|
|
Hi,
i m using : webBrowser1.Navigate("E:/map.htm?long1=12&lat=12");
the map is drawing by google maps API
again: if i paste this link (E:/map.htm?long1=12&lat=12) into my chrome browser its work perfect!
but when using the webbrowser contor i got nothing.
this is local file.
this is realy crazy , i just cant find the reason for this problem.
|
|
|
|
|
amiraf123 wrote: again: if i paste this link (E:/map.htm?long1=12&lat=12) into my chrome browser its work perfect!
That's hardly the same; the WebBrowser is based on IE, not on Chrome. If you want to use Chrome as a control, you'll have to download the Awesomium component.
The WebBrowser control would also adhere to the security-settings of IE - check whether JavaScript is enabled.
|
|
|
|
|
Hi Eddy,
I solved the problem by uploading the map.htm file to free web server.
It seems like the problem was becouse the i tried to Navigate to the file on my local machine.
So now the Navigate method is path is to the file on the server.
Thanks !
|
|
|
|
|
I am new to WCF REST service and Bing Map APIs...
Can anyone please tell me where to start... I got the Bing Map key... Where do I (which namespace) find the Bing Map APIs (Routes API etc) and add to my project reference?
Thanks.
|
|
|
|
|
Don't repost. It's a weekend - have a little patience!
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
|
Richard,
Thanks for the links... I read those links... But they don't explain which namespace or dill file I have to reference etc... I just need a quick tutorial how to use the BIng Maps Route APIs ... Thanks
|
|
|
|
|
Vijay Kanda wrote: I just need a quick tutorial how to use the BIng Maps Route APIs I am afraid that you will have to look for it yourself. This site exists to help people with specific technical problems, but we do not have the time (or in my case the skills) to provide tutorials on every subject in the IT field.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I am creating a REST Service project (just for learning purpose) and using Bing Map... This is what I want to accomplish...I am sending my current location (Latitude and longitude) to the service and I want to find out all the nearest Mac Donalds (for example) within 1 mile range from my current location and the distance and the time it will take me to get each Mac Donalds... I know there are BING MAP APIs which I can use to accomplish ...
But I never used BING map or rest service before... so can anyone please tell me the Bing Map method/API names which take latitude and longitude as argument and retrun the info that I mentioned above.
Thanks.
|
|
|
|
|
Have a look at Sacha Barber's his zombie article covers most of what you are after.
You can find the article here on CP. I would post a link but I'm writing this on a phone
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Simon,
Thanks... really appreciate it... I could not find the article which you mentioned... please let me know the url when you have a chance...
Thanks again.
|
|
|
|
|
|
Guys,
Create a console application. Select the project name in the solution explorer and Alt-Enter or right-click the properties and select the Application tab. Change the Target Framework to say 3.5 or something else other than 2.0. Paste this line into the Main method:
Console.WriteLine("Version=" + Assembly.GetExecutingAssembly().ImageRuntimeVersion);
and run it. I was sort of expecting to see it display the target framework I selected. Instead it displays v.2.0.50727 even though my target framework was set to 3.5. Obviously, I've misunderstood that line of code. Does anyone know what I can do to get the target version I selected? I don't want to do anything as a result of getting it so I just want to display it.
"I do not have to forgive my enemies, I have had them all shot." — Ramón Maria Narváez (1800-68).
"I don't need to shoot my enemies, I don't have any." - Me (2012).
|
|
|
|
|
Odd. I pasted your code into my app, and it gave me
Version=v4.0.30319 Which is what I would expect for a V4.0 C# app.
Are you sure you compiled and ran the right version?
Have you tried a full rebuild?
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
OG, I did indeed a clean and a full rebuild. Eddy Vluggen's reply after yours might well be the thing that decides what gets returned. I'll rebuild it in VS2012 and see what pops out of the woodwork as my VS2008 only lists upto 3.5.
"I do not have to forgive my enemies, I have had them all shot." — Ramón Maria Narváez (1800-68).
"I don't need to shoot my enemies, I don't have any." - Me (2012).
|
|
|
|
|
PHS241 wrote: Instead it displays v.2.0.50727 even though my target framework was set to 3.5.
.NET 2.0 would report the 2.0 framework, but 3.0 and 3.5 are "extensions" to the 2.0 runtime. 4.0 has a new runtime again, so that will report back version 4.
--edit;
There's a distinction between the target-framework, and the supported runtime. If it's a desktop-application, than you'll have an app.config file in there, and an "appname.exe.config" file in your Debug folder.
See MSDN[^].
modified 8-Dec-12 11:40am.
|
|
|
|
|
Thanks Eddy. I'll research the config setting in more detail.
"I do not have to forgive my enemies, I have had them all shot." — Ramón Maria Narváez (1800-68).
"I don't need to shoot my enemies, I don't have any." - Me (2012).
|
|
|
|
|
for (int i = 0; i < 5; i++)
{
i = int.Parse(Console.ReadLine());
}
Console.Write(i);
Console.ReadKey();
how to get console to print all of the numbers entered (5 numbers)? when i debug this it says that the name 'i' does not exist in current context.
|
|
|
|