This post has 3 Replies | 3 Followers

Top 10 Contributor
Male
Posts 33
Md. Elias Hossain Posted: 03-31-2009 10:45 AM

    While developing AJAX enabled(AJAX EXTENSION) website in VSTS 2008, once put ScriptManager control to the web page then after running the application which provide an error as "Sys is not Defined" and also show the error line as "Sys.Application.initialize();". So AJAX control doesn't work and  its simply refresh whole page and render the page while working with AJAX Extensions Tools.

    But while developing same type application in VS2005, no such type of error found.


    To get solution it needs some configuration changes at web.config file. For an unexperienced person its really hard to resolve this error. Previously I've faced this problem and also recently appeared this problem during developing a web site as AJAX Enabled(not with AJAX toolkits).

  There are few steps to solve this problem. The steps are given below to get solution as:

  1. Add configSections section in configuration Section with some configuration as:

    <configSections>
        <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
            <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
                <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
                <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
                    <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
                    <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
                    <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
                </sectionGroup>
            </sectionGroup>
        </sectionGroup>
    </configSections>

  2. Add Controls references in <pages> section in <system.web> section as:

        <pages>
            <controls>
                <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            </controls>
        </pages>

3. Add <assemblies> section in <compilation> section in <system.web> section as:

            <assemblies>
                <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            </assemblies>

4. Add <httpHandlers> section with some verbs in <system.web> section as:

        <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>

5. Add <httpModules> section with assembly types in <system.web> section as:

        <httpModules>
            <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        </httpModules>

6. Add <system.webServer> section just below </system.web> section as:

    </system.web>

        <!-- your others configuration  go here -->

    </system.web>

    <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
        <modules>
            <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        </modules>
        <handlers>
            <remove name="WebServiceHandlerFactory-Integrated"/>
            <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        </handlers>
    </system.webServer>

 

Thats all and the problem will be solved.

Hope this information will be helpful.

 

Thanks

Elias

Software Engineer

Desme Inc.

Md. Elias Hossain
MCP, MCTS(WEB)
Software Engineer

Top 50 Contributor
Male
Posts 2

Thanks for this Elias vai! This is why I prefer doing all Javascript and AJAX related stuff using JQuery. Even Kobe uses JQuery instead of the dreaded MSFT Ajax Toolkit.

Top 25 Contributor
Male
Posts 21

Yaa....jQuery is the best framework and very flexible, but if you use Microsoft Ajax, you can do some work in a fly with less code writing, that's why I love to use both. one of the main reason I love jQuery is that Visual Studio/web developer also support jQuery itellicense, and if you create a New project with visual studio 2008, by default you will get all(almost) web.config section to support MS Ajax....and for toolkit?you can always copy AjaxControlToolkit.dll file to your bin directory and start working.For web site development I think jQuery is the best and for web application development combination of both would be better.

Ashfaq

Top 10 Contributor
Male
Posts 33

Hi all,

   I forgot to mention one important thing that is:  Error: Sys is not defined ? will get when you want to use IDE of vs2008 but chosen framework is 3.0 or earlier, once select framework 3.5 the web.config file will be arranged automatically with the given section configuration so error will not appear.

  If you're using vs2005 but you didn't select your site as "AJAX Enabled" website type, then if you want to make your site AJAX enabled in future then you've to put the necessary dll(System.Web.Extensions.dll and System.Web.Extensions.Design.dll) to Bin folder and need to put the given sections configuration to your web.config file.

 

Thanks

Md. Elias Hossain
MCP, MCTS(WEB)
Software Engineer

Page 1 of 1 (4 items) | RSS