views:

57

answers:

1

I am trying to register below mentioned javascript for using with GridView to add freeze functioality on GridView. When compiling an error is thrown Microsoft JScript runtime error: 'Sys' is undefined

How it can be fixed.

<script language="javascript" type="text/javascript">
    // This Script is used to maintain Grid Scroll on Partial Postback
    var scrollTop;
    //Register Begin Request and End Request 
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
    //Get The Div Scroll Position
    function BeginRequestHandler(sender, args) 
    {
    var m = document.getElementById('divGrid');
    scrollTop=m.scrollTop;
    }
    //Set The Div Scroll Position
    function EndRequestHandler(sender, args)
    {
    var m = document.getElementById('divGrid');
    m.scrollTop = scrollTop;
    } 
</script>  
A: 
    <script type="text/javascript">
        var prm = Sys.WebForms.PageRequestManager.getInstance();
        prm.add_initializeRequest(initializeRequest);
        prm.add_endRequest(endRequest);
        var _postBackElement;</br>
        function initializeRequest(sender, e) 
     {
if (prm.get_isInAsyncPostBack()) 
{ e.set_cancel(true); }

    var m = document.getElementById('divGrid'); 
    scrollTop=m.scrollTop; 
    } 
    function endRequest(sender, e)
    { 
    var m = document.getElementById('divGrid'); 
    m.scrollTop = scrollTop;
    } 
            </script>



try adding the following in web.config under <system.web>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
Bala
@Bala: this code is still not working. I am getting the same error
Shantanu Gupta
Exception is being thrown on very first line i.e. Sys.WebForms.PageRequestManager.getInstance();
Shantanu Gupta
will it helps you?
Bala
@Bala: No this didn't worked for me. I am using ToolScriptManager instead of ScriptManager.
Shantanu Gupta