mshtml HTMLFormElement events

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sunny

    #1

    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_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
  • Jeffrey Tan[MSFT]

    #2
    RE: mshtml HTMLFormElement events


    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.

    Comment

    • Sunny

      #3
      RE: mshtml HTMLFormElement events

      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 <0fsWt5xsDHA.29 72@cpmsftngxa07 .phx.gbl>, v-
      jetan@online.mi crosoft.com says...[color=blue]
      >
      > 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.
      >
      >[/color]

      Comment

      • Jeffrey Tan[MSFT]

        #4
        RE: mshtml HTMLFormElement events


        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.

        Comment

        • Sunny

          #5
          RE: mshtml HTMLFormElement events

          In article <vzEnr9$sDHA.20 48@cpmsftngxa06 .phx.gbl>, v-
          jetan@online.mi crosoft.com says...[color=blue]
          >
          > 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.
          >
          >[/color]
          Thanks
          I'll wait.

          Sunny

          Comment

          • Jeffrey Tan[MSFT]

            #6
            RE: mshtml HTMLFormElement events


            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.

            Comment

            • Ariel Molina

              #7
              RE: mshtml HTMLFormElement events

              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

              Comment

              • Sunny

                #8
                RE: mshtml HTMLFormElement events

                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$9lcd0uDHA.73 6@cpmsftngxa07. phx.gbl>,
                arielm@online.m icrosoft.com says...[color=blue]
                > 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
                >
                >[/color]

                Comment

                • Ariel Molina

                  #9
                  RE: mshtml HTMLFormElement events

                  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

                  Comment

                  • Murali K

                    #10
                    RE: mshtml HTMLFormElement events

                    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!

                    Comment

                    • wisejedi7@yahoo.com

                      #11
                      Re: mshtml HTMLFormElement events

                      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

                      Comment

                      Working...