0

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,

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"),

How I can make the Update panel to updated?

Default.aspx.cs code:

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:

 <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?

DatRid
  • 1,169
  • 2
  • 21
  • 46
Shlomi Elbaz
  • 59
  • 1
  • 5

1 Answers1

0

If you want to make the UpdatePanel get Updated by CodeBehind use:

pnl.Update();

For sure you need to call it after your changes you did. (e.g. you added a Button into your UpdatePanel.)

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();
    }
}
DatRid
  • 1,169
  • 2
  • 21
  • 46