1

I used an UpdatePanel to prevent the whole page from reloading when I click on the button.

I did my code well, and I tried to prevent the page from loading when I click the button, but the page reloads again regardless. How can I solve this problem?

<asp:UpdatePanel ID="dd" runat="server">
<ContentTemplate>
<asp:Panel ID="PostPanel" Style="display: none" runat="server">
    <div class="modalPopup">
        <div class="PopupBody">
            <p class="ads-text">
                Go </p>
        </div>
        <div class="Controls">
            <div class="post">
                <asp:Button Text="OK" runat="server" ID="btnOkay" ValidationGroup="AddUserpopup"
                    OnClick="btnOkay_Click" />
            </div>
        </div>
    </div>
</asp:Panel>
 </ContentTemplate>
 <Triggers>
 <asp:AsyncPostBackTrigger  ControlID="btnOkay" EventName="CLick"/>
 </Triggers>
 </asp:UpdatePanel>
Josh Darnell
  • 11,304
  • 9
  • 38
  • 66
skdeveloper
  • 107
  • 1
  • 1
  • 12
  • 1
    The `AsyncPostBackTrigger` is redundant since you are not using `UpdateMode=Conditional`. By default all controls in the `UpdatePanel` post back asynchronously. – Tim Schmelter Jan 07 '14 at 21:34

1 Answers1

2

Try this. You need to set the UpdateMode and ChildrenAsTriggers properties. Also, your event name had incorrect capitalization.

<asp:UpdatePanel ID="dd" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
<ContentTemplate>
<asp:Panel ID="PostPanel" Style="display: none" runat="server">
    <div class="modalPopup">
        <div class="PopupBody">
            <p class="ads-text">
                Go </p>
        </div>
        <div class="Controls">
            <div class="post">
                <asp:Button Text="OK" runat="server" ID="btnOkay" ValidationGroup="AddUserpopup"
                    OnClick="btnOkay_Click" />
            </div>
        </div>
    </div>
</asp:Panel>
 </ContentTemplate>
 <Triggers>
 <asp:AsyncPostBackTrigger  ControlID="btnOkay" EventName="Click"/>
 </Triggers>
 </asp:UpdatePanel>
mason
  • 31,774
  • 10
  • 77
  • 121
  • Just a warning. jquery is incompatible with the updatepanel, calling any jquery function causes the UP to do a full postback. I ran into this, and after many hours of fiddling, I traced the problem down to jQuery. – MC9000 Sep 07 '18 at 05:59
  • 1
    @MC9000 Then you had a bug, because my company uses jQuery with UpdatePanel all the time. Not that I like it, but it does function. – mason Sep 07 '18 at 12:19
  • Not a bug, but a feature. LOL! I have many sites that use both, but, every single time a new javascript framework is introduced, it breaks all the hacks required to get it to work. For simple stuff, it works fine, then add auto-sizing tables, context sensitive dropdowns, etc, then it's just simpler to use jquery ajax. But they are incompatible out of the box. This much any dev will agree on. – MC9000 Sep 08 '18 at 00:51