By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,089 Members | 2,226 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,089 IT Pros & Developers. It's quick & easy.

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

Frinavale
Expert Mod 5K+
P: 9,731
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:

Expand|Select|Wrap|Line Numbers
  1.     _onScroll: function() {
  2. //this.get_element retrieves the <div> element
  3.         if (this.get_element()) {
  4.             this._LeftScrollPosition = this.get_element().scrollLeft;
  5. //scrollPositionMessenger is the hidden field that relays the scroll position to the server
  6.             var scrollPositionMessenger = document.getElementById(this._ScrollPositionMessengerName);
  7.             if(scrollPositionMessenger != null)
  8.             {
  9. //Error thrown here
  10.             scrollPositionMessenger.value=this._LeftScrollPosition;
  11.             }
  12.  
  13.         }
Does anyone know how to get around this problem?

Thanks for your time,

-Frinny
Mar 16 '09 #1
Share this Question
Share on Google+
14 Replies


acoder
Expert Mod 15k+
P: 16,027
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?
Mar 17 '09 #2

Frinavale
Expert Mod 5K+
P: 9,731
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.
Mar 17 '09 #3

acoder
Expert Mod 15k+
P: 16,027
You could use the URL or cookies.
Mar 17 '09 #4

Frinavale
Expert Mod 5K+
P: 9,731
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?
Mar 17 '09 #5

Frinavale
Expert Mod 5K+
P: 9,731
I found the answer to my question....
You can access the beginRequest event using the PageRequestManager 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 InitializeRequest Event...the value never makes it to the server.

This is very disappointing
[/edit]
Mar 17 '09 #6

acoder
Expert Mod 15k+
P: 16,027
@Frinavale
Try the onsubmit event. When the page is submitted, you can set the hidden field just the once.
Mar 18 '09 #7

Frinavale
Expert Mod 5K+
P: 9,731
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.
Mar 18 '09 #8

acoder
Expert Mod 15k+
P: 16,027
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)?
Mar 18 '09 #9

Frinavale
Expert Mod 5K+
P: 9,731
That's what I'm trying to do.

I was attempting to set the HiddenField value in the beginRequest event, or in the initializeRequest 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
Mar 18 '09 #10

Frinavale
Expert Mod 5K+
P: 9,731
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.
Mar 18 '09 #11

Frinavale
Expert Mod 5K+
P: 9,731
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 PageRequestManager's initializeRequest event.

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

The event arguments parameter is an InitializeRequestEventArgs 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
Mar 18 '09 #12

acoder
Expert Mod 15k+
P: 16,027
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.
Mar 18 '09 #13

Frinavale
Expert Mod 5K+
P: 9,731
I was setting it before the Ajax call. I was setting it in the "onscroll" event....however, 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 initializeRequest 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.
Mar 18 '09 #14

acoder
Expert Mod 15k+
P: 16,027
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.
Mar 19 '09 #15

Post your reply

Sign in to post your reply or Sign up for a free account.