为你的aspx页面加上ajax enable

今天想在以前做的一个项目里的一些页面添加AJAX Extent控件,但是将控件一拉到页面上就出现了
"尝试读取或写入受保护的内存.这通常指示其他内存已损坏."
难道安装的文件出错了?我又重新安装了一次,提示重启,完了之后打开工程,重新操作,但是问题依旧.搞什么鬼呢?仔细想了想,原来是我的工程不是AJAX enable的.郁闷了,那不是要重新新建项目?
突然想起以前看过的一篇文章,通过改配置文件就可以使页面支持ajax控件的使用.但是现在又找不到了,唯有自己尝试吧.

新建一个ajax enable工程,打开里面的配置文件,打开本来工程的配置文件,开始比较了.
1.<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 >
2.
<system.web>节
(1)<pages>
     < pages >
      
< controls >
        
< add  tagPrefix ="asp"  namespace ="System.Web.UI"  assembly ="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      
</ controls >
    
</ pages >
(2)<compilation>
< assemblies >
        
< add  assembly ="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      
</ assemblies >
(3)<httpModules>
     < httpModules >
      
< add  name ="ScriptModule"  type ="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    
</ httpModules >
3.添加了<system.web.extensions>,不过基本上没有内容
   < system .web.extensions >
    
< scripting >
      
< webServices >
      
<!--  Uncomment this line to customize maxJsonLength and add a custom converter  -->
      
<!--
      <jsonSerialization maxJsonLength="500">
        <converters>
          <add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/>
        </converters>
      </jsonSerialization>
      
-->
      
<!--  Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate.  -->
      
<!--
        <authenticationService enabled="true" requireSSL = "true|false"/>
      
-->

      
<!--  Uncomment these lines to enable the profile service. To allow profile properties to be retrieved
           and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and
           writeAccessProperties attributes. 
-->
      
<!--
      <profileService enabled="true"
                      readAccessProperties="propertyname1,propertyname2"
                      writeAccessProperties="propertyname1,propertyname2" />
      
-->
      
</ webServices >
      
<!--
      <scriptResourceHandler enableCompression="true" enableCaching="true" />
      
-->
    
</ scripting >
  
</ system.web.extensions >
4.添加了<system.webServer>
   < 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 >

到这里,原来没有的东西,都Copy过去了,保存,然后把控件一拉,OK!原来就这么简单.现在整个项目的页面都支持ajax控件的使用了.记住,下次别忘了

你可能感兴趣的:(为你的aspx页面加上ajax enable)