2009-08-06 8 views
1

J'ai un problème avec UpdatePanel où il provoque toujours une publication en pleine page au lieu d'une publication asynchrone.UpdatePanel provoque la publication en pleine page

est ici code ASPX

<%@ Page language="c#" Codebehind="RegistrationsOld.aspx.cs" AutoEventWireup="True" Inherits="Registrations.Register" %> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 
<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
     <title>Registrations</title> 
    </head> 
    <body> 
     <form id="_mainForm" runat="server"> 
      <asp:ScriptManager ID="_scriptManager" runat="server"></asp:ScriptManager> 
      <asp:UpdatePanel ID="_updatePanel" runat="server"> 
       <ContentTemplate> 
        <asp:Button ID="_postBack" runat="server" Text="Postback!!!" /> 
        <%=DateTime.Now%> 
       </ContentTemplate> 
      </asp:UpdatePanel> 
     </form> 
    </body> 
</html> 

Aucun code derrière la logique

Dans le résultat HTML je remarque que toute la logique javascript pour l'enregistrement UpdatePanels est manquant, ce qui peut se tromper?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 
<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
     <title>Registrations</title> 
    </head> 
    <body> 
     <form name="_mainForm" method="post" action="RegistrationsOld.aspx" id="_mainForm"> 
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="FKfjiCZfvms4LEL11blfrXnmC/wScY2XjDvMtkIBXPqdutqXjc+flWgtcQ5WHHxU" /> 


<script src="/Registrations/ScriptResource.axd?d=ZqE69ckaWSPtXLlB_ypEoaexcnFR_4HaKEIAj2L1SjguUUzm1b2ynhnRSUdcjmkKP0wNTeyoNrwIk6T5YgXcACfck9AjnPvFflFbAgvZJgM1&amp;t=633306437776352439" type="text/javascript"></script> 
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="YJ2A6HeD5ZInaAtsQI6zV2+cnGmR39d5mvZmEVdtWCHnBZriZCyd4g==" /> 

      <div id="_updatePanel"> 

        <input type="submit" name="_postBack" value="Postback!!!" id="_postBack" /> 
        8/6/2009 5:23:40 PM 

</div> 


<script type="text/javascript"> 
<!-- 
Sys.Application.initialize(); 
// --> 
</script> 
</form> 
    </body> 
</html> 

C'est le fichier web.config

<?xml version="1.0"?> 
<configuration> 
    <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> 

    <connectionStrings> 
     <add name="ConnectionString" connectionString="server=xxx.xxx.xxx.xxx;Trusted_Connection=false;database=Portal;User ID=*****;Password=*****;Enlist=False" 
      providerName="Company.Framework.Data.Providers.SqlServerDatabase, Company.Framework.Data" /> 
     <add name="TestConnectionString" connectionString="Data Source=xxx.xxx.xxx.xxx;Initial Catalog=Portal;User ID=*****;Password=*****" 
      providerName="System.Data.SqlClient" /> 
    </connectionStrings> 
    <appSettings> 
     <add key="SiteLink" value=""/> 
     <add key="EnableMail" value="false"/> 
    </appSettings> 
    <system.web> 
     <pages validateRequest="true"> 
      <controls> 
       <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> 
      </controls> 
     </pages> 
     <authorization> 
      <allow users="?"/> 
     </authorization> 
     <!-- set debugmode to false for running application --> 
     <compilation debug="true"/> 
     <!--The Portal Starter Kit supports either Forms authentication (Internet) 
      or Windows authentication (for intranets). Forms Authentication is 
      the default. To change to Windows authentication, comment the 
      <authentication mode="Forms"> section below, and uncomment the 
      <authentication mode="Windows"> section. --> 
     <!--<sessionState timeout="60" cookieless="false" />--> 
     <authentication mode="None"/> 
     <!--<authentication mode="Windows" /> 
     <authorization> 
      <deny users="?" /> 
     </authorization>--> 
     <httpRuntime useFullyQualifiedRedirectUrl="true"/> 
     <globalization fileEncoding="utf-8" requestEncoding="utf-8" uiCulture="en-US" culture="en-US" responseEncoding="utf-8"/> 
     <!-- Adapter configuration for mobile controls used in the portal --> 
     <mobileControls> 
      <device name="PortalHtmlDeviceAdapters" inheritsFrom="HtmlDeviceAdapters"> 
       <control name="ASPNET.StarterKit.Portal.MobileControls.TabbedPanel, ASPNETPortal" adapter="ASPNET.StarterKit.Portal.MobileControls.HtmlTabbedPanelAdapter,ASPNETPortal"/> 
       <control name="ASPNET.StarterKit.Portal.MobileControls.LinkCommand, ASPNETPortal" adapter="ASPNET.StarterKit.Portal.MobileControls.HtmlLinkCommandAdapter,ASPNETPortal"/> 
      </device> 
      <device name="PortalChtmlDeviceAdapters" inheritsFrom="ChtmlDeviceAdapters"> 
       <control name="ASPNET.StarterKit.Portal.MobileControls.TabbedPanel, ASPNETPortal" adapter="ASPNET.StarterKit.Portal.MobileControls.ChtmlTabbedPanelAdapter,ASPNETPortal"/> 
      </device> 
      <device name="PortalWmlDeviceAdapters" inheritsFrom="WmlDeviceAdapters"> 
       <control name="ASPNET.StarterKit.Portal.MobileControls.TabbedPanel, ASPNETPortal" adapter="ASPNET.StarterKit.Portal.MobileControls.WmlTabbedPanelAdapter,ASPNETPortal"/> 
      </device> 
     </mobileControls> 
     <!-- Mobile device filters used for customizing portal --> 
     <deviceFilters> 
      <filter name="isJScript" compare="javascript" argument="true"/> 
      <filter name="isPocketIE" compare="browser" argument="Pocket IE"/> 
      <filter name="isHTML32" compare="preferredRenderingType" argument="html32"/> 
     </deviceFilters> 
     <trace enabled="true"/> 
     <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"/> 
      <remove verb="GET" path="FtbWebResource.axd" /> 
      <remove verb="POST,GET" path="ajaxpro/*.ashx" /> 
      <!--<add verb="GET" 
       path="FtbWebResource.axd" 
       type="FreeTextBoxControls.AssemblyResourceHandler, FreeTextBox" /> --> 
     </httpHandlers> 
     <httpModules> 
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> 
     </httpModules> 
     <machineKey validationKey="AutoGenerate" decryptionKey="AutoGenerate" validation="3DES"/> 
     <customErrors mode="Off"/> 
     <xhtmlConformance mode="Legacy"/> 
    </system.web> 
</configuration> 

Merci à l'avance

+0

ce qui est des underscores dans les propriétés id? –

Répondre

4

J'ai trouvé que le problème est le problème !!!

Ainsi, note mentale: Rejeter utilisation de xhtmlComformance: D

Plus d'informations peuvent être trouvées here.

Extrait:

Sauf si vous connaissez des problèmes connus que votre site a lors de l'exécution en mode XHTML (et que vous n'avez pas le temps encore à fixer), je toujours recommande de retirer la section de votre fichier web.config (ou vous pouvez explicitement le définir sur "Transitional" ou "Strict").

Cela rendra vos normes de sortie HTML conformes. Entre autres choses, le HTML de vos contrôles serveur sera "bien formé", ce qui signifie que les éléments de balise open et close correspondent toujours. Ceci est particulièrement important lorsque vous utilisez des techniques AJAX pour remplacer dynamiquement le contenu de certains éléments HTML sur votre page (sinon le JavaScript côté client devient parfois confus au sujet des éléments du conteneur et peut conduire à des erreurs). Il veillera également à ce que ASP.NET AJAX fonctionne correctement avec votre site.

+1

Je ne pense pas que ce soit un problème. Nous utilisons UpdatePanel avec la conformité DHTML dans toutes nos pages. Donc, dites-vous que la suppression de la conformité a automatiquement fait que le panneau de mise à jour envoie seulement une publication partielle de page? –

+1

XhtmlComformance à Legacy était le problème http://weblogs.asp.net/scottgu/archive/2006/12/10/gotcha-don-t-use-xhtmlconformance-mode-legacy-with-asp-net-ajax .aspx – Paleta

-2

Ma première idée serait de supprimer underscores de tous les noms d'identification.

0

Vous devrez peut-être ajouter "EnablePartialRendering = true" au gestionnaire de script

+1

C'est la valeur par défaut, mais vaut la peine d'être essayée. –

Questions connexes