|
Good answer, and I've already thought of that. What I am having a problem with is images, say, via the <img> tag in my HTML and I reference a file also in my resources. It's not working when I call up the HTML in the WebBrowser . I have, e.g., a file called studioheader.png in my resources, and the HTML I load (through the WebBrowser.DocumentText property) is, just as a simple example:
<html>
<head>
<title>Start Pagestudioheader.PNG is in my Resources. The very same HTML is loaded into the WebBrowser.DocumentText property on Form_Load event, but when I bring up the form in my app, the WebBrowser control does not display the image. I don't want to put the image on some server somewhere; I want to bundle it with my application resources, so I can depend on it always showing up, no matter where my app is installed.
Sincerely Yours,
Brian Hart
|
|
|
|
|
Hi Brian,
there is a solution to that, not a very simple one though. It basically consists of embedding a web server into your application, and letting your WebBrowser show actual pages originating from that web server. The complexity depends on the features you would want; just delivering files should be very easy (remember, each image just causes another HTTP GET request to the server, and gets answered by sending the image file). Things would become real complex if you want to handle forms, AJAX, etc.
I trust CodeProject holds some decent articles on the subject, maybe tthis one[^] could help.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
I have a small app I wrote last year that opens 3 work-related web pages in separate tabs. Never had a moment's trouble until today. For no apparent reason the WebBrowser control no longer navigates. I get a "Navigation to web page was canceled" message. IE and FireFox are both working fine. Good strong Internet connection. If I set the WebBrowser to open in a new window, IE opens as expected and navigates to the proper page. My control's AllowNavigation property is still set to True.
The code below is from a test app I wrote to see if the problem was unique to my application, but it doesn't work either.
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
WebBrowser1.Navigate(txt.Text)
End Sub
If I change the Navigate statement to WebBrowser1.Navigate(txt.Text, True) it opens IE and goes to the desired page. Anyone have an idea? The program was working fine before and I've made no changes, so I'm a bit stumped.
|
|
|
|
|
|
I am using an HP, but the solutions offered from the search (both Google and Yahoo) were specific to a popup window displaying the "Navigation to the webpage was cancelled" message. Both IE and FF are working okay and the two tasks listed in the solutions are not present on my machine. Only the VS WebBrowser control is affected.
The only new thing I've done with VS lately is the addition to the toolbox of a 3rd party edit control (ScintillaNet). The control is not used in this project however and I can't imagine how it'd affect the WebBrowser (although my imagination is somewhat limited).
Stumped in Mississippi
|
|
|
|
|
Hi Alan,
I just experimented with a WebBrowser and it works as I would expect (Vista, IE7, .NET 2.0), e.g. navigating to "www.google.com".
Did you recently upgrade your IE (WebBrowser is or uses parts of IE)?
And does it fail on all kinds of URLs?
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Haven't upgraded lately. The WebBrowser fails with every url I try.
Also, the failure is immediate. There is no long pause as though it's trying to load (like with a weak WiFi signal). I get the "Canceled" message in 1 or 2 seconds.
Is it possible that the application can't connect for some reason?
|
|
|
|
|
Alan Burkhart wrote: Is it possible that the application can't connect for some reason?
I'm sure there is, but I'm not aware of any.
What is the exact symptom? are you getting an exception? if so, I suggest you look at Exception.ToString(), which shows all the available details (as opposed to Exception.Message).
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Not getting any exceptions. Just the browser message.
Using slightly different code in test app, and now the message is "This program cannot display the webpage."
Public Class Form1
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
Try
WebBrowser1.Navigate("http://www.google.com/")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub WebBrowser1_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated
txt.Text = WebBrowser1.Url.ToString
End Sub
End Class
|
|
|
|
|
Any chance you have a FireWall blocking your app completely?
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Found a suggestion: in IE(7) goto Tools/Internet Options/Advanced/ and uncheck "Show friendly HTML error messages", then try again to see the real problem.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Same result.
But... I just discovered that my Norton is shut down and won't run. Could be a related security issue. When I try to start Norton I get a little dialog thanking me for being a Norton BETA tester (never been one).
I'm off to grab the AVG freebie until I get Norton figured out. Perhaps the two problems have a common root? Stranger things have happened.
Will post back here when I'm done.
Thanks!
AB
|
|
|
|
|
It was Norton. The whole program was messed up and I had to reinstall. Now it's running fine, and the WebBrowser control is loading pages as it should.
Thanks so much for taking the time to help and have a great weekend when it gets here!
AB
|
|
|
|
|
You're welcome.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Hi All,
In our company we are making extensive use of the above mentioned component.
Because of the STA nature of this component we have many challenges in our code to fight threading issues related to this component. (and lots of other non-deterministic behaviour)
Does anybody know if there is a HTML Component available which is simular to the MSHTML component which is not based on this component. (or any other COM/PIA component)
Where looking for a true .NET component which can run safely within a MTA application.
Thanks for your time.
Extra info Component is both used in Windows and Web app
Groetjes,
Joost Verdaasdonk
modified on Thursday, September 17, 2009 11:05 AM
|
|
|
|
|
Hi All,
Good to see that I'm not the only one who finds this question hard to answer.
I'm still hoping on some lost component fullfilling my requirments.
If you know of one let me know.
Thanks.
Groetjes,
Joost Verdaasdonk
|
|
|
|
|
Thanks in adv.
how can we change the type of the control of Tool Strip like from button to Drop down button at run time
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
softdev_sup wrote: how can we change the type of the control of Tool Strip like from button to Drop down button at run time
Don't.
At least don't start with a ToolStripButton , make it a ToolStripDropDownButton from the start, and use the ShowDropDownArrow property to turn the dropdown functionality on and of as required.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
thanks for the post
but how can i add toolstripdropdown at run time , how to specofy that the type is dropdown or combobox or something else
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
How to: Add ToolStrip Items Dynamically - MSDN[^], will tell you how to do that.
softdev_sup wrote: how to specofy that the type is dropdown or combobox or something else
They are all separate classes, duplicate what is done in the tutorial given above and replace their control with one of your choosing. Take a look at the entry for ToolStrip on MSDN ToolStrip Control (Windows Forms) - MSDN[^]. There are loads of links on that page. Follow them in turn. Read the ones that are textual, code the ones that are examples (if you take my advice type the code in you learn far more that way, don't copy and paste it!).
The only real way to learn how to use the built in controls, is to research them properly. Start on MSDN, then google for more help on things you don't understand.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thank You so so much , GOD bless You
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
I work for a company that has developed a library for user authentication, and it uses this library for authenticating users that access the web site using Web Forms and ASP.NET. However, this isn't the focus of this post (or it would be obviously in the wrong place). For those who want to get to the point quickly, the real question is at the very end.
I have been tasked to create a Winforms C# application that also authenticates a user, and I am wanting to use this same library. I have installed the library locally, and it's working fine as in the following example:
private bool EncryptPassword(ref string PW)
{
Type Crypto;
object[] parameter = new object[1];
object CryptoObject;
try
{
Crypto= Type.GetTypeFromProgID("CCDUserLib.Crypto");
CryptoObject = Activator.CreateInstance(Crypto);
parameter[0] = PW;
object result = Crypto.InvokeMember("EncryptedPassword",
System.Reflection.BindingFlags.InvokeMethod, null,
CryptoObject, parameter);
PW = result.ToString();
return true;
}
catch
{
return false;
}
}
From what I understand, System.Type.GetTypeFromProgID("CCDUserLib.Crypto") searches the registry for the registered library "CCDUserLib". I am hoping that I don't have to install the CCD library locally, but instead reference the library that is already installed on our Web Server (which is not the workstation this software is going to be run on).
Is there any way to dynamically bind to a library that is installed on a different machine (like "\\CCDWebServer\bin\CCDUserLib.dll"), assuming the user has sufficient access rights to do so?
Thanks,
Daniel Bragg
|
|
|
|
|
You can't instantiate an object from a class that is not registered on the machine the code is running on. You also, cannot tell it where to find the class without the registration information in the registry.
You either have to install the library on the client workstation or you have to redesign the app to support creating the library objects on a remote server. That will introduce some performance, possibly licensing, and supportability issues, so that may not be the best course of action.
|
|
|
|
|
Thanks. Although licensing wouldn't be an issue (we wrote the library that we want to call), I don't believe it would be worth the effort to make it work this way. I'll just include the library in the distributables and call it done.
Daniel
|
|
|
|
|
Hi everybody,
When we use the Graphics object to draw, for example, on a Form, every time, something covers the entire or just a part of the Form (for example, another window) or when the Form is minimized and them maximized for example, all the drawn graphics are lost (or the part present on the covered part of the Form).
I wanted to know if there's anyway to retain these graphics in these cases? I don't (and can't) use the Paint method because I'm considering a case where the graphics are drawn using different method and not a single method to be called in the Paint event.
|
|
|
|
|