0

I have a simple ASP.NET 4.0 web form which has an UpdatePanel with a button and TextBox inside. There is nothing unusual about it (it is not inside a repeater and it is not inside a dynamic control).

Asynchronous postback works fine on my test server which is Windows Server 2003.

However, when I copy to my web hosting company (smarterasp.net, Server 2012) it does a full postback. I tried all of the settings available in the hosting control panel but nothing worked (eg. HTTP compression, Integrated mode, output caching).

Are there any usual causes for why this happens on different servers?

<asp:UpdatePanel ID="panSlug" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <div class="form-group">
            <asp:Label ID="lblSlug" runat="server" AssociatedControlID="txtSlug" Text="Slug"></asp:Label>
            <div class="input-group">
                <asp:TextBox ID="txtSlug" runat="server" CssClass="form-control" MaxLength="100"></asp:TextBox>
                <span class="input-group-btn">
                    <asp:Button ID="btnSlugSuggest" runat="server" CssClass="btn btn-default" OnClick="btnSlugSuggest_Click" Text="Suggest" />
                </span>
            </div>
            <asp:RequiredFieldValidator ID="valSlug" runat="server" ControlToValidate="txtSlug" Display="None" ErrorMessage="Slug is a required field" ValidationGroup="Product"></asp:RequiredFieldValidator>
            <p class="help-block">Slug is the URL of the product (no spaces or non alpha numeric characters)</p>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>

Looking at the output HTML on the local server the button renders as input type button with an onclick event, whereas on the live server it renders as a submit button with no onclick event.

In Developer Tools console two errors are shown: "ASP.NET Ajax client-side framework failed to load" and "Sys is not defined".

johna
  • 10,540
  • 14
  • 47
  • 72
  • Seems related: http://stackoverflow.com/questions/654423/button-in-update-panel-is-doing-a-full-postback – Sherman Oct 13 '14 at 01:42
  • Thanks @Nahrehs, but no answers there seem to help me. Both servers are running 4.0 and my local is IIS6, no sure what the live one is but must be 7.x or later. – johna Oct 13 '14 at 02:08

2 Answers2

1

It turns out that I had a page route set in global.asax that was preventing the axd files from loading.

I was missing routes.Ignore("{resource}.axd/{*pathInfo}"); from global.asax.

Hopefully this answer will help someone else as another possible solution to problems with UpdatePanels.

johna
  • 10,540
  • 14
  • 47
  • 72
0

Add this to the UpdatePanel:

<Triggers>
    <asp:AsyncPostBackTrigger ControlID="btnSlugSuggest" />
</Triggers>
Sherman
  • 853
  • 5
  • 16
  • Have you tried using the F12 tools and seeing if there are any errors being reported in the console? – Mark Fitzpatrick Oct 13 '14 at 01:10
  • There's no errors. Just a full postback occurs. Looking at source, the button renders as a submit rather than a button with an onclick event. – johna Oct 13 '14 at 01:24
  • Sorry there are errors: "ASP.NET Ajax client-side framework failed to load" and "Sys is not defined". – johna Oct 13 '14 at 02:30
  • http://stackoverflow.com/questions/11288796/asp-net-ajax-client-side-framework-failed-to-load-when-put-the-scriptmanager-on – Sherman Oct 13 '14 at 02:35
  • That's your smoking gun. Namrehs link should help out. The scripts aren't being served properly. If the site is using authentication, make sure that the various .axd handlers and css/js directories have anonymous access enabled. If these are denied then the scripts can't be served. – Mark Fitzpatrick Oct 13 '14 at 02:40