IE8 "Data Execution Prevention" error thrown when setting hidden field value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #1

    IE8 "Data Execution Prevention" error thrown when setting hidden field value

    I've been trying to test my web application using Internet Explorer 8 (release candidate 1) and have been experiencing some major problems. I'm hoping you can help me with this one.

    I have a JavaScript Object that tracks the horizontal scroll position of a <div> element on the page. It sets a hidden field so that when the page is submitted to the server, the server code is able to retrieve the current scroll position. When the page is sent back to the browser, the server side code initializes the JavaScript Object with the scroll position retained.

    This has all been working for quite some time now....but with the new IE8 RC1 I'm getting a Data Execution Prevention error message. It's displayed in a prompt informing me that:
    Data Execution Prevention helps protect against damage from viruses and other security threats.
    When I hit the "close message" button in this prompt IE8 proceeds to crash.

    This message appears when I am storing the scroll position of the <div> in the hidden field used to relay the scroll position to the server:

    Code:
        _onScroll: function() {
    //this.get_element retrieves the <div> element
            if (this.get_element()) {
                this._LeftScrollPosition = this.get_element().scrollLeft;
    //scrollPositionMessenger is the hidden field that relays the scroll position to the server
                var scrollPositionMessenger = document.getElementById(this._ScrollPositionMessengerName);
                if(scrollPositionMessenger != null)
                {
    //Error thrown here
                scrollPositionMessenger.value=this._LeftScrollPosition;
                }
    
            }
    Does anyone know how to get around this problem?

    Thanks for your time,

    -Frinny
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    I don't know why it triggers that error, but a quick search on "Data Execution Prevention" shows that you can switch it off in non-64bit versions of IE8. Does that help?

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      It doesn't help because the end users shouldn't have to be playing around their browser settings while using my web application.

      I'm attempting to find a solution that doesn't involve a hidden field...but have no idea how I'm going to accomplish this yet.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        You could use the URL or cookies.

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          After much debugging I determined that I am able to set the value of the HiddenField using my JavaScript Object; however, setting it during the "onscroll" event is causing IE to crash. It does a nice little memory dump. I think that the scrolling action is too fast for it to properly manage the memory it takes to grab a reference to the HiddenField and set it's value. (I think this because if I set breakpoints during the scrolling it sets the HiddenField properly and doesn't crash, but under normal usage it causes the Data Execution Prevention exception...or, if I scroll too quickly, it just crashes)

          Instead of setting the HiddenField during the onscroll event I would love to set the HiddenField before the page is submitted... is it possible to implement the JavaScript Object in such a way that it is aware of a page submit?

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            I found the answer to my question....
            You can access the beginRequest event using the PageRequestMana ger in the .NET Ajax Framework.

            My problem now is that the HiddenField has an empty string when it the request gets to the server.

            At least IE's not crashing any more.

            Thanks for your help Acoder.

            [edit]
            I thought I had found the answer but apparently I cannot set the HiddenField during the beginRequest nor can I set it in the InitializeReque st Event...the value never makes it to the server.

            This is very disappointing
            [/edit]

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              Originally posted by Frinavale
              Instead of setting the HiddenField during the onscroll event I would love to set the HiddenField before the page is submitted... is it possible to implement the JavaScript Object in such a way that it is aware of a page submit?
              Try the onsubmit event. When the page is submitted, you can set the hidden field just the once.

              Comment

              • Frinavale
                Recognized Expert Expert
                • Oct 2006
                • 9749

                #8
                I tried your recommendation and it didn't work....

                Sorry, I should have been more clear about what I meant when I said "page submit". The scroll position needs to be stored in the hidden field during an asynchronous post back to the server (Ajax call). So, the onsubmit event never occurs in this situation.

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  Well, why not set it just before the Ajax call or pass the scroll value in the URL (GET) or in the send() method (POST)?

                  Comment

                  • Frinavale
                    Recognized Expert Expert
                    • Oct 2006
                    • 9749

                    #10
                    That's what I'm trying to do.

                    I was attempting to set the HiddenField value in the beginRequest event, or in the initializeReque st event. Both of these events occur before the Ajax call is executed; however, at this point, (I think) the request has already been created and so changing the HiddenField value in these events is useless.

                    I'm not sure how I would pass the value via the URL (GET method) using JavaScript.

                    Since my web application uses POST, I'm more interested in how I would pass the value using the send() method....since I don't know how to do this I'm going to look into it now.

                    Thanks for the suggestion!

                    -Frinny

                    Comment

                    • Frinavale
                      Recognized Expert Expert
                      • Oct 2006
                      • 9749

                      #11
                      So, way back, when I was just learning about Ajax (thanks to this forum actually)... I used the XMLHttpRequest' s open() and send() methods to preform an Ajax call to the server. I had completely forgotten about these methods because I've been using the .NET Ajax Framework for some time now.

                      The send method takes an optional parameter: the entity body.

                      Urg, I think I know how to do this, but it's going to be really nasty.

                      Comment

                      • Frinavale
                        Recognized Expert Expert
                        • Oct 2006
                        • 9749

                        #12
                        Thanks Acoder!

                        I have a solution to the problem. (I think) It involved modifying the parameter being set to the send() method by the .NET Ajax Framework.

                        In order to do this I had to implement a method that is executed during the PageRequestMana ger's initializeReque st event.

                        This method is passed 2 parameters: the sender, and the event arguments for the event.

                        The event arguments parameter is an InitializeReque stEventArgs Object. This object has a property that lets you retrieve the "request" Object.

                        The request object contains the body of the request which (I'm assuming) is sent as a parameter to the send() method. I was able to retrieve the body, modify the value for the hidden field in the body, and reset the request object's body with the changes.


                        Thanks a lot Acoder.

                        If it wasn't for you I would never have attempted any of this.

                        -Frinny

                        Comment

                        • acoder
                          Recognized Expert MVP
                          • Nov 2006
                          • 16032

                          #13
                          I'm glad you got it working in the end. I don't know if this would be possible with ASP.NET Ajax, but I would've taken my first suggestion for an easier and simpler solution, i.e. set the hidden field just before the Ajax call.

                          Comment

                          • Frinavale
                            Recognized Expert Expert
                            • Oct 2006
                            • 9749

                            #14
                            I was setting it before the Ajax call. I was setting it in the "onscroll" event....howeve r, this was crashing IE8. There may be another way to do this, but after days of trying to find a solution, I couldn't find one. The initializeReque st event was the only event that that I could use which occurred before the Ajax call...and at that point the request object is already created...so I had no choice but to edit the request body before the Ajax call is made.

                            Comment

                            • acoder
                              Recognized Expert MVP
                              • Nov 2006
                              • 16032

                              #15
                              If that is indeed the case, then I'd consider it to be a flaw, i.e. that you can't call a function or add some code before an Ajax call.

                              Comment

                              Working...