1

After installing and adding DevExpress 15.2 components to my Visual Studio 2015, whatever I do I can't work with ms ajax update panel.

AsyncPostPack is never happening and Timer does not work anymore. triggers either within update panel or outside don't work anymore.

If I create a new project everything is fine but as soon as I add a single dx component to my page, I'm not able to work with ajax toolkit anymore

this is my page

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

and this is code-behind:

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();
    }

this is what i have as output. as you can see after clicking the button page is reloading...

enter image description here

this is my web.config file just in case you need:

 <!--
 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>
Ali.Rashidi
  • 1,284
  • 4
  • 22
  • 51
  • place button outside Update panel and then do aysnctrigger button id – Manish Goswami Aug 10 '16 at 06:24
  • ok. i will tell you. – Ali.Rashidi Aug 10 '16 at 06:25
  • should i put label inside update panel? – Ali.Rashidi Aug 10 '16 at 06:30
  • no. I put button outside updatepanel and then do as you said but it is refreshing page again. – Ali.Rashidi Aug 10 '16 at 06:32
  • I checked in both case it's working at my end. Can you place your Scriptmanagar in MasterPage Instead of in your current page and check – Manish Goswami Aug 10 '16 at 06:35
  • Is there any configuration settings in web.config or any thing else? i just read the Microsoft's blog and followed their instructions to do what i want but the page is always refreshing. – Ali.Rashidi Aug 10 '16 at 06:36
  • roger that. wait... – Ali.Rashidi Aug 10 '16 at 06:37
  • Is there anything in your page,that is refreshing the page at regular interval in meta tag check in master page. – Manish Goswami Aug 10 '16 at 06:38
  • i just put script manager inside master but it is again no use. – Ali.Rashidi Aug 10 '16 at 06:39
  • i tried it within a page without master page but it is the same again. looks like something is wrong, i mean maybe a configuration in somewhere. – Ali.Rashidi Aug 10 '16 at 06:40
  • There is no problem in code its fine. – Manish Goswami Aug 10 '16 at 06:41
  • im updating question, please take a look – Ali.Rashidi Aug 10 '16 at 06:43
  • to check both cases. none of them work. – Ali.Rashidi Aug 12 '16 at 07:30
  • @Ali.Rashidi, I tried your code and it's working fine, both buttons only produce a partial postback. Analyzing the network with the developer tool shows that the responses only contain the UpdatePanel. Does this page as-is produce a full page postback in your local? Have you tried with a new webforms project just in case there's some configuration causing the problem? – Andrew Aug 12 '16 at 07:44
  • I tried your code, it's really working very perfect – Udhay Titus Aug 12 '16 at 07:50
  • What are you expecting to happen? Like some others already mentioned the code is working just fine. What is happening inside `Button1_Click` and `Button2_Click`? Maybe the problem is in there... Post that and we can help you further. If for example there is a `Response.Write` in there it will not work. – VDWWD Aug 12 '16 at 19:51
  • "i want to change the text of label on button click without refreshing my page." You can not accomplish this using just an Update Panel. both you buttons will automatically cause a postback and refresh only the update panel. If what you are asking is for no postback(?), then you must use front-end code such as Javascript – DaniDev Aug 12 '16 at 23:37
  • thank you all for your comment. i agree that this code should work fine but not in my case. when i click on buttons, it should change the contents of label without refreshing the page. just like when you add a comment here. right? but when i click on button a "loading circle" appears in firefox tab. i mean it is not what it should be – Ali.Rashidi Aug 13 '16 at 05:36
  • @Andrew that behavior you said is expected but there is something wrong here. i tried to create new projects but nothing changed – Ali.Rashidi Aug 13 '16 at 05:57
  • `Button2_Click` will always do postback since is outside of `panel`... but `Button1` will do partial postback (let's say, refresh only `updatepanel`)... try to change to this ``... btw. postback will triggered always, I think, but only changes into `updatepanel` will be affected. – nelek Aug 13 '16 at 06:00
  • i used to do so but nothing changes – Ali.Rashidi Aug 13 '16 at 06:02
  • Did you try with another browser? How do you tell it's a full postback? – Andrew Aug 13 '16 at 13:50
  • because i have two controls, one within update panel another outside. when i click on button 1 only contents of one label should change but they change both. and yes i did try it on IE, firefox, Chrome – Ali.Rashidi Aug 13 '16 at 14:50

3 Answers3

1

Suggestion 1

Your code should work fine. It is normal for a button click to trigger a postback (as the name AsyncPostBackTrigger indicates). However, only the content of the UpdatePanel should be refreshed.

A good way to test it is to add a Label outside of the UpdatePanel:

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

In code-behind, you can update both Labels when either button is clicked:

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();
}

If the partial update works correctly, you should see that Label1 is updated when a button is clicked, while Label2 is not.


Suggestion 2

Since the configuration setting <xhtmlConformance mode="Legacy"/> can cause the kind of behavior that you see in your application (as reported in UpdatePanel causes full page postback), you can eliminate that potential problem with the following setting in your Web.config file:

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

Suggestion 3

In some situations where no DevExpress component is visible in the page, the following code must be executed to make sure that the client scripts are registered (see this discussion on DevExpress technical support forum):

protected void Page_Load(object sender, EventArgs e)
{
    ASPxWebControl.RegisterBaseScript(this);
}
Community
  • 1
  • 1
ConnorsFan
  • 70,558
  • 13
  • 122
  • 146
  • i did as exactly you said. and uploaded a photo as a result. there is a postback but a full post back. – Ali.Rashidi Aug 13 '16 at 05:43
  • contents of both labels change. is there something wrong in configuration file or maybe vs2015 or anything else? – Ali.Rashidi Aug 13 '16 at 05:49
  • I added a suggestion for the `xhtmlconformance` setting in Web.config. – ConnorsFan Aug 13 '16 at 14:56
  • i really hate such problems. thank you but did not solved the problem. can be there something wrong about "Ajax client framework" ? – Ali.Rashidi Aug 13 '16 at 15:02
  • At this point, I don't know what causes your problem. I would like to test your configuration but there are several references to DevExpress components, which I don't have. Can you make a new project without any reference to these components? – ConnorsFan Aug 13 '16 at 15:11
  • yes! it is working now. but i need that project to use ajax not this one. what causes the problem? – Ali.Rashidi Aug 14 '16 at 13:30
  • That gives you a way to debug the problem. You can gradually introduce the DevExpress components in the Web.config of the new project, until you find the problematic setting/component. Once you find it, we can see if there is something to do about it. – ConnorsFan Aug 14 '16 at 13:59
  • I added a 3rd suggestion. You can give it a try. – ConnorsFan Aug 17 '16 at 21:35
  • i started to learn about DevExpress CallbackPanel. that is much easier and better. it seems DX disables ajax for some configuration reasons. if i give this bounty to no one after tomorrow, will it be mine again or do I have to give it to someone? – Ali.Rashidi Aug 18 '16 at 05:14
  • anyway I think you deserve this 50 :) – Ali.Rashidi Aug 18 '16 at 05:16
  • Thanks. I had seen discussions about the CallbackPanel but I thought there was a way to use the UpdatePanel with DevExpress (trying to answer your question). Just curious: did you try `RegisterBaseScript` with the UpdatePanel? – ConnorsFan Aug 18 '16 at 12:00
  • no actually. sometimes ignoring problems is better than to solve them . never mind. – Ali.Rashidi Aug 19 '16 at 10:14
0

Make sure your browser supports partial rendering (which it likely does), and that EnablePartialRendering is true. The default is true which is probably why it works for others, but there are also some underlying requirements for ScriptManager that may not be met on your system, causing it to be false. See EnablePartialRendering and SupportsPartialRendering for example.

You may also want to review the UpdatePanel Control Overview on MSDN for more detail on the requirements and gotchas of using this control.

brichins
  • 3,825
  • 2
  • 39
  • 60
0

try to add "UseSubmitBehavior="false""

<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"/>
Mustapha Larhrouch
  • 3,373
  • 3
  • 14
  • 28