将DevExpress组件添加到项目后,MS Ajax Update Panel无法运行

时间:2016-08-10 06:16:20

标签: c# asp.net ajax devexpress

在我的Visual Studio 2015中安装和添加DevExpress 15.2组件之后,无论我做什么,我都无法使用ms ajax更新面板。

AsyncPostPack永远不会发生,Timer不再起作用。在更新面板内或外部触发不再起作用。

如果我创建一个新项目一切都很好但是只要我在页面中添加一个dx组件,我就不能再使用ajax工具包了

这是我的页面

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ajax.aspx.cs" Inherits="bimehPortal.ajax" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Label ID="Label1" runat="server" Text="Label" />
                <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
        <asp:Label ID="Label2" runat="server" Text="Label" />
        <asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" />
</div>
</form>
</body>
</html>

这是代码隐藏的:

protected void Button1_Click(object sender, EventArgs e)
    {
        UpdateLabels();
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        UpdateLabels();
    }
    private void UpdateLabels()
    {
        Label1.Text = DateTime.Now.ToString();
        Label2.Text = DateTime.Now.ToString();
    }

这就是我的输出。正如您在单击按钮页面后所看到的那样正在重新加载......

enter image description here

这是我的web.config文件,以防您需要:

 <!--
 For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
 <configuration>
 <configSections>
    <sectionGroup name="devExpress">
        <section name="themes" type="DevExpress.Web.ThemesConfigurationSection, DevExpress.Web.v15.2, Version=15.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirePermission="false"/>
        <section name="compression" type="DevExpress.Web.CompressionConfigurationSection, DevExpress.Web.v15.2, Version=15.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirePermission="false"/>
        <section name="settings" type="DevExpress.Web.SettingsConfigurationSection, DevExpress.Web.v15.2, Version=15.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirePermission="false"/>
        <section name="errors" type="DevExpress.Web.ErrorsConfigurationSection, DevExpress.Web.v15.2, Version=15.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirePermission="false"/>
    </sectionGroup>
</configSections>
<!--
    For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.

    The following attributes can be set on the <httpRuntime> tag.
        <system.Web>
            <httpRuntime targetFramework="4.5.1" />
        </system.Web>
-->
<system.web>
    <compilation debug="true" targetFramework="4.5.1">
        <assemblies>
            <add assembly="DevExpress.Web.v15.2, Version=15.2.10.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A"/>
            <add assembly="DevExpress.Data.v15.2, Version=15.2.10.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A"/>
            <add assembly="DevExpress.Printing.v15.2.Core, Version=15.2.10.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A"/>
            <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="DevExpress.RichEdit.v15.2.Core, Version=15.2.10.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A"/>
            <add assembly="System.Web.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="DevExpress.Web.ASPxThemes.v15.2, Version=15.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"/>
            <add assembly="DevExpress.Web.ASPxPivotGrid.v15.2, Version=15.2.10.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A"/>
            <add assembly="DevExpress.PivotGrid.v15.2.Core, Version=15.2.10.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A"/></assemblies>
    </compilation>
    <httpRuntime targetFramework="4.5.1"/>
    <pages>
        <namespaces>
            <add namespace="System.Web.Optimization"/>
        </namespaces>
        <controls>
            <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt"/>
        </controls>
    </pages>
    <httpModules>
        <add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v15.2, Version=15.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule"/>
    </httpModules>
    <httpHandlers>
        <add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v15.2, Version=15.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET" path="DX.ashx" validate="false"/>
    </httpHandlers>
</system.web>
<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed"/>
            <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
        </dependentAssembly>
        <dependentAssembly>
            <assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35"/>
            <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234"/>
        </dependentAssembly>
    </assemblyBinding>
</runtime>
<system.codedom>
    <compilers>
        <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
        <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
    </compilers>
</system.codedom>
<system.webServer>
    <modules>
        <add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v15.2, Version=15.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule"/>
    </modules>
    <validation validateIntegratedModeConfiguration="false"/>
    <handlers>
        <add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v15.2, Version=15.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET" path="DX.ashx" name="ASPxHttpHandlerModule" preCondition="integratedMode"/>
    </handlers>
</system.webServer>
<devExpress>
    <themes enableThemesAssembly="true" styleSheetTheme="" theme="" customThemeAssemblies=""/>
    <compression enableHtmlCompression="false" enableCallbackCompression="true" enableResourceCompression="true" enableResourceMerging="true"/>
    <settings doctypeMode="Html5" rightToLeft="false" embedRequiredClientLibraries="false" ieCompatibilityVersion="edge"/>
    <errors callbackErrorRedirectUrl=""/>
</devExpress>
<appSettings>
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
</appSettings>
</configuration>

3 个答案:

答案 0 :(得分:1)

建议1

您的代码应该可以正常运行。按钮单击触发回发是正常的(名称为AsyncPostBackTrigger表示)。但是,只应更新UpdatePanel的内容。

测试它的一个好方法是在UpdatePanel之外添加一个Label:

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Label ID="Label1" runat="server" Text="Label" />
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>
<asp:Label ID="Label2" runat="server" Text="Label" />
<asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click"/>

在代码隐藏中,您可以在单击任一按钮时更新两个标签:

protected void Button1_Click(object sender, EventArgs e)
{
    UpdateLabels();
}

protected void Button2_Click(object sender, EventArgs e)
{
    UpdateLabels();
}

private void UpdateLabels()
{
    Label1.Text = DateTime.Now.ToString();
    Label2.Text = DateTime.Now.ToString();
}

如果部分更新正常,您会看到点击按钮时Label1已更新,而Label2则不会。

建议2

由于配置设置<xhtmlConformance mode="Legacy"/>可能导致您在应用程序中看到的行为类型(如UpdatePanel causes full page postback中所述),因此您可以使用{{1中的以下设置消除该潜在问题文件:

Web.config

建议3

在某些页面中看不到DevExpress组件的情况下,必须执行以下代码以确保客户端脚本已注册(请参阅DevExpress技术支持论坛上的this discussion):

<system.web>
    ...
    <xhtmlConformance mode="Transitional"/>
</system.web>

答案 1 :(得分:0)

确保您的浏览器支持部分呈现(可能会这样做),EnablePartialRenderingtrue。默认值为true,这可能是它适用于其他人的原因,但是在您的系统上可能无法满足ScriptManager的一些基本要求,导致它为false。例如,请参阅EnablePartialRenderingSupportsPartialRendering

您可能还想查看MSDN上的UpdatePanel Control Overview,详细了解使用此控件的要求和难点。

答案 2 :(得分:0)

尝试添加&#34; UseSubmitBehavior =&#34; false&#34;&#34;

<asp:Button ID="Button1" UseSubmitBehavior="false" runat="server" Text="Button" OnClick="Button1_Click" />

<asp:Button ID="Button2" UseSubmitBehavior="false" runat="server" Text="Button" OnClick="Button2_Click"/>