0

There is a form which contain a tabcontainer and watermark control from ajaxcontroltoolkit. It's Giving java error: Sys.Extended is undefined when using the following gzip procedure. The following code is from Global.asax file :

void Application_PreRequestHandlerExecute(object sender, EventArgs e)
    {
        HttpApplication app = sender as HttpApplication;
        string acceptEncoding = app.Request.Headers["Accept-Encoding"];
        Stream prevUncompressedStream = app.Response.Filter;

        if (!(app.Context.CurrentHandler is Page ||
            app.Context.CurrentHandler.GetType().Name == "SyncSessionlessHandler") ||
            app.Request["HTTP_X_MICROSOFTAJAX"] != null)
            return;

        if (acceptEncoding == null || acceptEncoding.Length == 0)
            return;

        acceptEncoding = acceptEncoding.ToLower();

        if (acceptEncoding.Contains("deflate") || acceptEncoding == "*")
        {
            // defalte
            app.Response.Filter = new DeflateStream(prevUncompressedStream,
                CompressionMode.Compress);
            app.Response.AppendHeader("Content-Encoding", "deflate");
        }
        else if (acceptEncoding.Contains("gzip"))
        {
            // gzip
            app.Response.Filter = new GZipStream(prevUncompressedStream,
                CompressionMode.Compress);
            app.Response.AppendHeader("Content-Encoding", "gzip");
        }
    }

When I remove the above code the error is gone and everything works fine.

This is the control tag from web.config:

<controls>
    <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add tagPrefix="ajaxToolkit" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>
    <add tagPrefix="HTMLEditor" namespace="AjaxControlToolkit.HTMLEditor" assembly="AjaxControlToolkit"/>
</controls>

When I run alert(Sys.Extended.UI.TabPanel); in firebug console I got error "Sys.Extended is undefined". But when I run only alert(Sys.Extended); is gives message "undefined" not error. Does this makes any sense?. And I also wants to mention that when I save the page from browser I gives a message "default.js could not be saved, because the source file could not be read" and I didn't find the .js file of page in page default_files folder. But when I remove the gzip code from global.asax file I found the default.js file in default_files folder.

Zubarik
  • 107
  • 1
  • 2
  • 9

1 Answers1

0

Are your using the ToolKitScriptManager? If so check that the composite scripts are in the correct order:

<compositescript>
    <scripts>
        <asp:scriptreference name="WebForms.js" assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" scriptmode="Release"></asp:scriptreference>    
        <asp:scriptreference name="WebUIValidation.js" assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" scriptmode="Release"></asp:scriptreference>    
        <asp:scriptreference name="MicrosoftAjax.js" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" scriptmode="Release"></asp:scriptreference>    
        <asp:scriptreference name="MicrosoftAjaxWebForms.js" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" scriptmode="Release"></asp:scriptreference>
    </scripts>
</compositescript>

There are more possiblities mentioned in Sys is undefined

Community
  • 1
  • 1
DaveB
  • 9,470
  • 4
  • 39
  • 66
  • Yes, I'm using ToolkitScriptManager, But I didn't find the compositescript tag in web.config. Version I'm using is ASP.NET 2.0 in VS2008. – Zubarik Sep 24 '12 at 02:17
  • @Zubarik - Perhaps you might try adding it and see if the problem is cured. – DaveB Sep 24 '12 at 15:58
  • No, the problem is still there: "default.js could not be saved, because the source file could not be read". default.js not found which causing "Sys is undefined" error... – Zubarik Sep 25 '12 at 02:29