AxWebBrowser - create a document on the fly?
-
Hi everyone, I have a
AxSHDocVw.AxWebBrowser
on a Form in my Windows Forms application. Now, is it possible somehow to create an HTML document on the fly (programmatically from my Windows Forms application) that will be displayed instead of navigating to an existing document usingAxWebBrowser.Navigate(...)
? Thanks for any clues in advance! Rado -
Hi everyone, I have a
AxSHDocVw.AxWebBrowser
on a Form in my Windows Forms application. Now, is it possible somehow to create an HTML document on the fly (programmatically from my Windows Forms application) that will be displayed instead of navigating to an existing document usingAxWebBrowser.Navigate(...)
? Thanks for any clues in advance! RadoFunnily enough I was doing this very same thing today. I couldnt find a way to, for example, pass in a HTML string and get the browser to render it. So, using the data from the form components I created a HTML string and used a FileStream to write the this to a temporary file, I then used : object obj = null; myBrowser.Naviagate(pathToFile, ref obj, ref obj ref ob ref obj, ref obj) Note : I may have not typed in the right amount of "ref obj" as I am doing this from memory. post.mode = postmodes.signature; SELECT everything FROM everywhere WHERE something = something_else; > 1 Row Returned > 42
-
Funnily enough I was doing this very same thing today. I couldnt find a way to, for example, pass in a HTML string and get the browser to render it. So, using the data from the form components I created a HTML string and used a FileStream to write the this to a temporary file, I then used : object obj = null; myBrowser.Naviagate(pathToFile, ref obj, ref obj ref ob ref obj, ref obj) Note : I may have not typed in the right amount of "ref obj" as I am doing this from memory. post.mode = postmodes.signature; SELECT everything FROM everywhere WHERE something = something_else; > 1 Row Returned > 42
What you're both going to need to learn to use is MSHTML. Which is basically DHTML. So if you already know DHTML it makes it really easy. If you don't know DHTML but you understand XML, then you shouldn't have too many problems. So what you're going to need to do is get ahold of the Body element of the Document page and insert the HTML that you need by either creating the elements on the fly which is the most correct way, or by doing something like body.InnerHTML = "my html stuff". If this doesn't make any sense I'll try to find you some links that I used to learn it.
-
What you're both going to need to learn to use is MSHTML. Which is basically DHTML. So if you already know DHTML it makes it really easy. If you don't know DHTML but you understand XML, then you shouldn't have too many problems. So what you're going to need to do is get ahold of the Body element of the Document page and insert the HTML that you need by either creating the elements on the fly which is the most correct way, or by doing something like body.InnerHTML = "my html stuff". If this doesn't make any sense I'll try to find you some links that I used to learn it.
Navigating to a local file is fine, in fact, Reflector used to do this in a version a while ago (I haven't checked to see how Lutz is doing it now). - Nick Parker
My Blog | My Articles -
What you're both going to need to learn to use is MSHTML. Which is basically DHTML. So if you already know DHTML it makes it really easy. If you don't know DHTML but you understand XML, then you shouldn't have too many problems. So what you're going to need to do is get ahold of the Body element of the Document page and insert the HTML that you need by either creating the elements on the fly which is the most correct way, or by doing something like body.InnerHTML = "my html stuff". If this doesn't make any sense I'll try to find you some links that I used to learn it.
That's the way I went in the end, because I didn't want to write to a temporary file each time. I have created an HTML template document with a few elements, like a header and text field, and then used MSHTML to locate these elements and set their innerHTML attributes. Looked like a more elegant way for my purpose. :) If anyone needs the code, I can post it here, it was just a few lines. Rado
-
That's the way I went in the end, because I didn't want to write to a temporary file each time. I have created an HTML template document with a few elements, like a header and text field, and then used MSHTML to locate these elements and set their innerHTML attributes. Looked like a more elegant way for my purpose. :) If anyone needs the code, I can post it here, it was just a few lines. Rado
And of course you can just navigate to "about:blank" and it will load an empty document immediately. Judah Himango