如何在不重新加载包含WebForm的情况下重新加载UserControl? [英] How to reload a UserControl without reloading the containing WebForm?
问题描述
我有一个WebForm(使用母版页创建)。这个WebForm包含一个UserControl,我想在UserControl外部和WebForm内的按钮的ButtonClick事件上重新加载这个UserCOntrol。我怎样才能做到这一点?我不想重新加载整个WebForm。
< < span class =code-leadattribute> asp:UpdatePanel runat = server id = UpdatePanel updatemode = 条件 < span class =code-keyword>>
< 触发器 >
< asp:AsyncPostBackTrigger controlid = Button1 eventname = 点击 / >
< / Triggers >
< ContentTemplate >
< uc2:GetUserScraps ID = GetUserScraps1 runat = server / >
< / ContentTemplate > ;
< / asp:UpdatePanel >
我不知道怎么做Code Behind?
我也遇到这个问题,我得到了解决方法
< asp:UpdatePanel runat = server id = UpdatePanel updatemode = 条件 >
< ContentTemplate >
< uc2:GetUserScraps ID = GetUserScraps1 < span class =code-attribute> runat = server / >
< / ContentTemplate >
< / asp:UpdatePanel >
从按钮点击事件后面的代码更新此面板,例如
UpdatePanel.Update()
如果表中的设计结构使用更新面板,例如
< < span class =code-leadattribute> asp:UpdatePanel ID = updpnlRefresh runat = server < span class =code-attribute> UpdateMode = 条件 >
< ContentTemplate >
//您的表格结构
I have a WebForm(created using a master page). THis WebForm contains a UserControl and i want to reload this UserCOntrol on ButtonClick event of a button which is outside the UserControl and inside the WebForm. How can i do this? I do not want to reload entire WebForm.
<asp:UpdatePanel runat="server" id="UpdatePanel" updatemode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger controlid="Button1" eventname="Click" />
</Triggers>
<ContentTemplate>
<uc2:GetUserScraps ID="GetUserScraps1" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
I am not sure what to do on Code Behind?
I also suffer from this problem and i get soln
<asp:UpdatePanel runat="server" id="UpdatePanel" updatemode="Conditional"> <ContentTemplate> <uc2:GetUserScraps ID="GetUserScraps1" runat="server" /> </ContentTemplate> </asp:UpdatePanel>
Update this panel from code behind on button click event like
UpdatePanel.Update()
If your design structure in table use update panel like
<asp:UpdatePanel ID="updpnlRefresh" runat="server" UpdateMode="Conditional"> <ContentTemplate>
//Your table structure
这篇关于如何在不重新加载包含WebForm的情况下重新加载UserControl?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!