[英]Update panel inside Server Control
I'm trying to update panel content by using __DePostBack
call to the server, the HTTP server side is fired but the panel won't updates, 我正在尝试通过使用对服务器的__DePostBack
调用来更新面板内容,HTTP服务器端被触发,但是面板不会更新,
The update panel is in custom server control and it unfamiliar to the PAGE context and I can reach it only by using: FindControl("Update Panel ID")
, 更新面板位于自定义服务器控件中,它不熟悉PAGE上下文,我只能通过以下方式访问它: FindControl("Update Panel ID")
,
How I can make the Update panel to updated? 如何使“更新”面板更新?
Default.aspx.cs code: Default.aspx.cs代码:
protected void Page_Load(object sender, EventArgs e)
{
string _action = this.Request.Params.Get("__EVENTTARGET");
if (_action == "XX")
{
UpdatePanel pnl = ((UpdatePanel)TabControl1.FindControl("UpdatePanel ID"));
UserControl uc = (UserControl)LoadControl("MyForm.ascx");
pnl.ContentTemplateContainer.Controls.Clear();
pnl.ContentTemplateContainer.Controls.Add(uc);
}
}
Default.aspx code: Default.aspx代码:
<SDMS:TabControl ID="TabControl1" BorderColor="#00F" runat="server" class="tabswrapper">
<TabPages>
<SDMS:TabPage ID="TabPage6" runat="server" UpdateContent="UpdatePanel1" Title="Two">
<TabBody>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<ContentTemplate>
</asp:UpdatePanel>
</TabBody>
</SDMS:TabPage>
</TabPages>
</SDMS:TabControl>
How I can make the updated Panel to be updated? 如何使已更新的面板得以更新?
If you want to make the UpdatePanel get Updated by CodeBehind use: 如果要使UpdatePanel通过CodeBehind获得更新,请使用:
pnl.Update();
For sure you need to call it after your changes you did. 当然,更改后需要调用它。 (eg you added a Button into your UpdatePanel.) (例如,您在UpdatePanel中添加了一个Button。)
So with your code it should work with this: 因此,对于您的代码,它应该可以使用:
protected void Page_Load(object sender, EventArgs e)
{
string _action = this.Request.Params.Get("__EVENTTARGET");
if (_action == "XX")
{
UpdatePanel pnl = ((UpdatePanel)TabControl1.FindControl("UpdatePanel ID"));
UserControl uc = (UserControl)LoadControl("MyForm.ascx");
pnl.ContentTemplateContainer.Controls.Clear();
pnl.ContentTemplateContainer.Controls.Add(uc);
pnl.Update();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.