473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

mshtml HTMLFormElement events

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_page = this.mydoc.Document as mshtml.HTMLDocumentClass;

if (this.current_page != null)
{
mshtml.IHTMLElementCollection _forms = this.current_page.forms;

foreach (mshtml.IHTMLFormElement _form in _forms)
{
((mshtml.HTMLFormElementEvents2_Event)_form).onsub mit +=
new mshtml.HTMLFormElementEvents2_onsubmitEventHandler
(MyDoc_onsubmit);
}
}

2.
<same, just diff. foreach>
foreach (mshtml.HTMLFormElementClass _form in this.forms)
{
_form.HTMLFormElementEvents2_Event_onsubmit +=
new mshtml.HTMLFormElementEvents2_onsubmitEventHandler
(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
Nov 15 '05 #1
10 7974

Hi Sunny,

You can set break point in the onsubmitEventHandler 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.

Nov 15 '05 #2
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.microsoft.com says...

Hi Sunny,

You can set break point in the onsubmitEventHandler 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.

Nov 15 '05 #3

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.

Nov 15 '05 #4
In article <vz**************@cpmsftngxa06.phx.gbl>, v-
je***@online.microsoft.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
Nov 15 '05 #5

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.

Nov 15 '05 #6
Hello Sunny,

I tried the code below:

private void DocumentComplete(object sender,
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
doc = (mshtml.HTMLDocument)axWebBrowser1.Document;
foreach (mshtml.IHTMLFormElement cform in doc.forms)
{
mshtml.HTMLFormElementEvents_Event iEvent;
iEvent = (mshtml.HTMLFormElementEvents_Event) cform;
iEvent.onsubmit += new
mshtml.HTMLFormElementEvents_onsubmitEventHandler( OnSubmitEventHandler);

}

}

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

Nov 15 '05 #7
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.microsoft.com says...
Hello Sunny,

I tried the code below:

private void DocumentComplete(object sender,
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
doc = (mshtml.HTMLDocument)axWebBrowser1.Document;
foreach (mshtml.IHTMLFormElement cform in doc.forms)
{
mshtml.HTMLFormElementEvents_Event iEvent;
iEvent = (mshtml.HTMLFormElementEvents_Event) cform;
iEvent.onsubmit += new
mshtml.HTMLFormElementEvents_onsubmitEventHandler( OnSubmitEventHandler);

}

}

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

Nov 15 '05 #8
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

Nov 15 '05 #9
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!
Nov 16 '05 #10
Hi Ariel,

I am working on a project that needs to capture the onsubmit event of a
form, and was wondering if there was any resolution to the problems
listed in this discussion. Thanks much.

Chris Mueller

Nov 16 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
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...
1
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...
0
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...
3
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...
5
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...
0
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 - ...
5
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...
0
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%...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.