ASP.NET - JavaScript error - Asked By Oded Dror on 09-Dec-16 01:58 PM

Hi there,


I follow the example ASP.NET GridView in scrollable DIV: Show selected row on click on your website

And I'm getting error in line  document.getElementById('MainContent_grid1Div').scrollTop = strPos;

JavaScript runtime error: Unable to set property 'scrollTop' of undefined or null reference

  

I'm using asp.net on VS2010 I placed the script in <asp:Content> section there is no runat=server

My asp.net (vb) page has site.master


When I click ignore it continue to do the job (basically is long list gridview inside div pick the clientId into another view (I have multi views page) inside the page that show client activity


my question is how to get rid of this error message or fix this issue?

Robbe Morris replied to Oded Dror on 09-Dec-16 01:59 PM
MainContent_grid1Div
is not getting returned as an element from document.getElementById.  Make sure you've set the "id" property of your div tag and not just the name.

<div id="MainContent_grid1Div"></div>
Oded Dror replied to Robbe Morris on 09-Dec-16 07:33 PM

Robbe,

 

It appears to be only when I'm running in VS debug mode IE only it runs fine on FF

When I deploy it to IIS it runs fine, Also when I took it out of the view control and lay it on the page itself it runs fine.

 

How do I close the issue? you can close it for me. 

 

Thank you

Oded Dror