Hi all,
dev. env.: VS.Net2003/C#
I have a windows form application with web browser control. I need to
capture the onsubmit event of the forms in the document in order to get
the values and log them.
I have tried this:
1.
this.current_pa ge = this.mydoc.Docu ment as mshtml.HTMLDocu mentClass;
if (this.current_p age != null)
{
mshtml.IHTMLEle mentCollection _forms = this.current_pa ge.forms;
foreach (mshtml.IHTMLFo rmElement _form in _forms)
{
((mshtml.HTMLFo rmElementEvents 2_Event)_form). onsubmit +=
new mshtml.HTMLForm ElementEvents2_ onsubmitEventHa ndler
(MyDoc_onsubmit );
}
}
2.
<same, just diff. foreach>
foreach (mshtml.HTMLFor mElementClass _form in this.forms)
{
_form.HTMLFormE lementEvents2_E vent_onsubmit +=
new mshtml.HTMLForm ElementEvents2_ onsubmitEventHa ndler
(MyDoc_onsubmit );
.....
And there are 2 articles on codeproject.com , they do not work also.
And ... no success. There is no exceprions, everything passes, but after
that the form submition on the page is blocked, even the submit button
does not work.
I have tried to go around this and to use BeforeNavigate2 event of the
browser (it works) and to examine if there is postdata. But in that case
I'll loose forms which has GET method.
Please, any help will be highly appreciated.
Thanks
Sunny 10 8027
Hi Sunny,
You can set break point in the onsubmitEventHa ndler to find if this method
was called.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Hi Jeffrey,
Thanks for the suggestion. I have already done this before I post. I'm
stating that it is not called, and I mean it.
Thanks
Sunny
In article <0f************ **@cpmsftngxa07 .phx.gbl>, v- je***@online.mi crosoft.com says... Hi Sunny,
You can set break point in the onsubmitEventHa ndler to find if this method was called.
Best regards, Jeffrey Tan Microsoft Online Partner Support Get Secure! - www.microsoft.com/security This posting is provided "as is" with no warranties and confers no rights.
Hi Sunny,
Yes, I have tried your solution 2. I did not find any error in your code.
I will do some search into this. I will reply you ASAP.
Thanks for your understanding.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
In article <vz************ **@cpmsftngxa06 .phx.gbl>, v- je***@online.mi crosoft.com says... Hi Sunny,
Yes, I have tried your solution 2. I did not find any error in your code. I will do some search into this. I will reply you ASAP. Thanks for your understanding.
Best regards, Jeffrey Tan Microsoft Online Partner Support Get Secure! - www.microsoft.com/security This posting is provided "as is" with no warranties and confers no rights.
Thanks
I'll wait.
Sunny
Hi Sunny,
Sorry for letting you wait so long.
I still did not figure out where is the problem. I have called some
colleague to handle this issue.
We will reply you ASAP.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Hello Sunny,
I tried the code below:
private void DocumentComplet e(object sender,
AxSHDocVw.DWebB rowserEvents2_D ocumentComplete Event e)
{
doc = (mshtml.HTMLDoc ument)axWebBrow ser1.Document;
foreach (mshtml.IHTMLFo rmElement cform in doc.forms)
{
mshtml.HTMLForm ElementEvents_E vent iEvent;
iEvent = (mshtml.HTMLFor mElementEvents_ Event) cform;
iEvent.onsubmit += new
mshtml.HTMLForm ElementEvents_o nsubmitEventHan dler(OnSubmitEv entHandler);
}
}
And was not able to sink the onsubmit event either. I was able to sink
other form element events however so this really is telling me that we may
be looking at a possible bug. For a workaround have you considered
sinking the onclick event of the submit button on the form? This should
accomplish the same thing.
Ariel Molina
Microsoft Online Support
Hello Ariel,
thanks for the post.
Yes, it seems that it is a bug, but can you provide me some more info
where is it - in the mshtml by itself, or in the wrapper for .Net?
I have solved the problem by capturing the BeforeNavigate2 event, and
examining Post == null of the provided event args.
But this, like sinking to the click event is half of the work.
If you hook to BeforeNavigate2 , you will miss the GET method forms.
And if you sink to the onclick event, you are not sure that the form is
submitted, because it may have some validation, and not always
submitted.
I'll be glad to hear about the progress in that direction.
Thanks
Sunny
In article <n$************ *@cpmsftngxa07. phx.gbl>, ar****@online.m icrosoft.com says... Hello Sunny,
I tried the code below:
private void DocumentComplet e(object sender, AxSHDocVw.DWebB rowserEvents2_D ocumentComplete Event e) { doc = (mshtml.HTMLDoc ument)axWebBrow ser1.Document; foreach (mshtml.IHTMLFo rmElement cform in doc.forms) { mshtml.HTMLForm ElementEvents_E vent iEvent; iEvent = (mshtml.HTMLFor mElementEvents_ Event) cform; iEvent.onsubmit += new mshtml.HTMLForm ElementEvents_o nsubmitEventHan dler(OnSubmitEv entHandler);
}
}
And was not able to sink the onsubmit event either. I was able to sink other form element events however so this really is telling me that we may be looking at a possible bug. For a workaround have you considered sinking the onclick event of the submit button on the form? This should accomplish the same thing.
Ariel Molina Microsoft Online Support
Hello Sunny,
The bug has been filed with the product group but at this time I cannot
give any details regarding the problem component. Just keep up to date
with the release notes for future versions of the products involved.
Thank You,
Ariel Molina
Microsoft Online Support
Is there any solution for the above mentioned issue? I am very
interested in the solution as I got into the same issue where the submit
button is completely disabled if a onsubmit event handler is attached to
the form.
I appreciate any help.
Murali
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Robert May |
last post by:
I have an application that uses the Ax web browser object. When I call the
IHTMLElement.click() method on an input button (<input type="submit"> or
<input type="button">), the click fires appropriately, if I'm running it
from a windows forms based application.
However, when I run the EXACT same code under a windows service, either as a
logged in user or as the local system account, the click fails to process.
Clicking on other elements...
|
by: Dean Hallman |
last post by:
I need to ensure client machine has Microsoft.mshtml installed in the GAC.
And if not, deploy it. My app is a Browser Helper Object and depends on
mshtml.
Initially, I thought I could take care of deploying mshtml within my install
..msi (VS.NET
setup/deploy project). But if I simply add mshtml to the GAC from my
install, the install
fails near the end with the error:
|
by: Giuseppe |
last post by:
Hi
I've this problem
Inside a winform application I've put a "webbrowser" control
I've tried to catch the oncontextmenu event of the loaded HTML document with the following
approach
1) In the event handler AxWebBrowser1.DocumentComplete I've put:
Dim doc As mshtml.HTMLDocument
|
by: ddd |
last post by:
I am trying to use MSHTML without the webbrowser and I am having a few
problems. Right now all I am trying to do is load an URL(html page) and
access its innerhtml.
What I have is:
Dim doc As mshtml.HTMLDocument = New mshtml.HTMLDocument()
Dim d1 As mshtml.IHTMLDocument4 = doc
Dim d2 As mshtml.IHTMLDocument4 = doc
d2.write("<html><body>test</body></html>")
|
by: Atara |
last post by:
I am trying to convert the following code to VB .Net, I still have some
gaps (the lines that are marked with (*))
and also I need an ending condition for the while loop.
any help would be appreciated.
Thanks. Atara.
-------------------------
Original code:
| |
by: Atara |
last post by:
Our application was build with VS 2003.
I have tried to run it on a computer with .Net 2.0 (but without .Net 1.1
, as it should be used)
and I got the following error -
System.InvalidCastException: Unable to cast COM object of type
'mshtml.HTMLBodyClass' to class type ''. COM components that enter the
CLR and do not support IProvideClassInfo or that do not have any interop
assembly registered will be wrapped in the __ComObject type....
|
by: miktro |
last post by:
I have an VB.Net desktop application where I am hosting a WebBrowser.
I need to interact with the events in the browser.
I encountered the normal problem of, after adding events the normal click
on the browser didn't work (in particular you can't enter text into
textareas).
I found the Microsoft KB article 311284 - "How to handle document evetns
in VB.Net" - and implemented the code.
|
by: Laurent Lequenne |
last post by:
Hello All,
I'm currently developing a free windows Scrabble (in french :)) application that uses extensively the WebBrowser class of NET 2.0 for configuration, and data browsing. It works 100% on my machine, with the WebBrowser Class, and the Microsoft.MsHtml component. I can access all elements on the pages through the events, I can change some parts. Everything is rendered with XSLTs and changing directly the document through the msHtml...
|
by: nickin4u |
last post by:
I have a application that is used to automate certain task,
I have been using mshtml.HTMLDocument class but certain events like click a button do not fire. I have tried a number of combinations but in vain.
I was now trying to use System.Windows.Forms.Htmldocument class; here is the code
Dim do1 As System.Windows.Forms.HtmlDocument = web1.Document
web1 is axwebbrowser
however when i execute the above line i get the error
cannot...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |