的UpdatePanel导致整页回传 [英] UpdatePanel causes full page postback

查看:91
本文介绍了的UpdatePanel导致整页回传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有的UpdatePanel一个问题,即它总是导致一整页回发,而不是一个异步之一。

I having an issue with UpdatePanel where its always causing a full page postback instead of an async one.

下面是ASPX code

Here's aspx code

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

背后的逻辑没有code

No code behind logic

在生成的HTML我注意到,所有登记的UpdatePanel的JavaScript逻辑缺失,还有什么能错了?

In the resulting HTML I'm noticing that all the javascript logic for registering UpdatePanels is missing, what can be wrong?

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

这是web.config文件

This is the web.config file

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

在此先感谢

推荐答案

我发现这个问题是问题!

I found the problem is the problem!!!

所以,精神注意:禁止使用xhtmlComformance的:D

So, mental note: Disallow use of xhtmlComformance :D

的更多信息,可以发现<一个href=\"http://weblogs.asp.net/scottgu/archive/2006/12/10/gotcha-don-t-use-xhtmlconformance-mode-legacy-with-asp-net-ajax.aspx\"相对=nofollow>这里。

More information can be found here.

摘录:

除非你知道你的网站在XHTML模式下运行时(和你没有时间尚未修复),我总是建议从你的web.config文件中删除部分具有已知问题(或者你可以明确地将其设置为过渡或严格)。

Unless you know of known issues that your site has when running in XHTML mode (and which you don't have time yet to fix), I'd always recommend removing the section from your web.config file (or you can explicitly set it to "Transitional" or "Strict").

这会使你的HTML输出符合标准。除其他事项外,这将导致从服务器的HTML控件被井形成了 - 这意味着打开和关闭标签元素总是匹配。当您正在使用AJAX技术来动态替换你的页面上的某些HTML元素的内容,这一点尤为重要(否则客户端JavaScript有时候会感到困惑容器元素,并可能导致错误)。它还将确保ASP.NET AJAX正常工作与您的网站。

This will make your HTML output standards compliant. Among other things, this will cause the HTML from your server controls to be "well formed" - meaning open and close tag elements always match. This is particularly important when you are using AJAX techniques to dynamically replace the contents of certain HTML elements on your page (otherwise the client-side JavaScript sometimes gets confused about container elements and can lead to errors). It will also ensure that ASP.NET AJAX works fine with your site.

这篇关于的UpdatePanel导致整页回传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆