UpdatePanel,Trigger PostBack和User Control如何在TabPanel中动态加载

时间:2012-03-18 14:57:48

标签: vb.net user-controls asp.net-ajax updatepanel tabpanel

好吗? 我有一个更新面板内的按钮,单击此按钮我正在尝试加载更新面板更新面板,在此我添加了一个usercontrol。这是动态完成的,没有成功。 有谁可以帮助我?

    Protected Sub btnNewRpt_Click(sender As Object, e As EventArgs) Handles btnNewRpt.Click
        Dim hydic As New HybridDictionary From {{"tabId", "tab1"},
                                                {"ucPath", "UCRelatorioNovo.ascx"},
                                                {"ucId", "uc1"}}

        buildControls(hydic)
    End Sub

Private Sub buildControls(ByVal hydic As HybridDictionary)
    Dim uc As UserControl = LoadControl(hydic("ucPath"))
    uc.ID = hydic("ucId")

    Dim tg As New PostBackTrigger With {.ControlID = uc.FindControl("btnLoadOtherUC").UniqueID}

    Dim up As New UpdatePanel With {.ID = "upTest"}
    up.ContentTemplateContainer.Controls.Add(uc)
    up.Triggers.Add(tg)

    Dim tp As New TabPanel With {.ID = hydic("tabId")}
    tp.Controls.Add(up)

    TabContainer1.Controls.Add(tp)
End Sub

错误描述是:找不到ID为“TabContainer1_tab1_upTest”的UpdatePanel。如果它正在动态更新,那么它必须位于另一个UpdatePanel内。

1 个答案:

答案 0 :(得分:0)

在TabContainer的TabPanel中放置UpdatePanel upTest ,而不是将TabContainer / TabPanel放在 upTest 中,如果你想更新它们,除了更新你的自定义控件之外,你可以只放置自定义控制 upTest