开发者

Refresh User Control without Refreshing the Page

开发者 https://www.devze.com 2022-12-25 09:46 出处:网络
I have a page and it has a button and a user control. I want to refresh the user control without refreshing the page.

I have a page and it has a button and a user control. I want to refresh the user control without refreshing the page.

I know I cannot do it otherwise so what I did is wrapped my user control inside the Update Panel.

<asp:TextBox ID="txtName" runat="server"></asp:TextBox><br />
<asp:Button ID="btnAdd" runat="server" Text="Add name to list" OnClick="btnAdd_Click" /><br /><br />

<asp:UpdatePanel ID="upShowNames" runat="server">
 <ContentTemplate>
     <uc1:ShowNames ID="ucShowNames" runat="server" />
 </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnAdd" />
    </Triggers>
</asp:UpdatePanel>

But 开发者_StackOverflow社区I still the control won't refresh. I also tried calling the update panels. The Update() method by changing its UpdateMode to Conditional but that does not work either...

Does anyone know how can I do it?


Please change these 2 things

<asp:UpdatePanel ID="upShowNames" runat="server" UpdateMode="Conditional">

<asp:AsyncPostBackTrigger ControlID="btnAdd" EventName="Click"/>

You missed the EventName on the postback trigger, once you add that, it should work :-)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号