调用父页面的子控件的一个UpdatePanel的更新 [英] call child control on parent page for an update of an updatepanel

查看:199
本文介绍了调用父页面的子控件的一个UpdatePanel的更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是RadTabStrip 2标签。我想OnTabClick的标签做页面上的UpdatePanel的更新。我遇到的问题是它没有找到子页面上的控制。

I am using a RadTabStrip for 2 tabs. I would like OnTabClick for the tab to do an update of the updatepanel on the page. The problem I am having is its not finding the control on the child page.

我的父页面逻辑

protected void tabClick(object sender, RadTabStripEventArgs e)
{

    if (e.Tab.SelectedIndex == 0)
    {
        UpdatePanel tab1 = (UpdatePanel)Page.FindControl("up_EntirePage_Tab1");
        tab1.Update();
    }
    else
    {
        UpdatePanel tab2 = (UpdatePanel)Page.FindControl("up_EntirePage_Tab2");
        tab2.Update();

    }
}

所以up_EntirePage_Tab1和up_EntirePage_Tab2像这样对他们的尊重页。

So up_EntirePage_Tab1 and up_EntirePage_Tab2 look like this on their respected pages.

<asp:UpdatePanel ID="up_EntirePage_Tab1" runat="server">
<asp:UpdatePanel ID="up_EntirePage_Tab2" runat="server">

和RadTabStrip看起来像这样父页上

and the RadTabStrip looks like so on the parent page

<telerik:RadTabStrip ID="RadTabStrip1" runat="server" SelectedIndex="0" 
            Height="100%"  MultiPageID="RadMultiPage1" OnTabClick="tabClick">
            <Tabs>
                <telerik:RadTab runat="server" PageViewID="t1" Text="Assign Events To Categories" >
                </telerik:RadTab>
                <telerik:RadTab runat="server" PageViewID="t2" Text="Assign User Types To Events" 
                    Selected="True">
                </telerik:RadTab>
            </Tabs>
</telerik:RadTabStrip>

不知道我需要做的,以实现这一目标。

Not sure what I need to do in order to make this happen.

pretty的多选项卡1我有一个列表,如果我添加到它,它会更新罚款。现在,如果我点击选项卡包含相同的列表不会被更新。所以我想呼吁尊重页的UpdatePanel切换时应该拉正确的信息的页面更新。

Pretty much on Tab 1 I have a list that if I add to it, it will update fine. Now if I was to click on tab 2 that contains the same list it will not be updated. So I figure calling the updatepanel on the respected pages to update when switching should pull the correct information for the page.

如果有一个更简单的方法,甚至更优的方法,我将AP preciate的帮助,但现在我目前的方法甚至无法工作。我得到一个空引用,因为我发现控制找不到的UpdatePanel。

If there is an easier method or even more optimal method I would appreciate the help but for now my current method won't even work. I am getting a null reference because my find control can't find the updatepanel.

编辑:的UpdatePanel都在用户控件TABS1和TAB2。它们是两个独立的用户控制。

The updatepanels are in the usercontrols tabs1 and tab2. They are two separate user controls.

推荐答案

好吧,在你的用户控件,你需要在两个用户控件创建属性的UpdatePanel。

Ok , In your usercontrol you need to create property for UpdatePanel on both UserControls.

有关TAB1 UserControl1上

For Tab1 on Usercontrol1

     public UpdatePanel Tab1UpdatePanel
    {
        get
        {
            return up_EntirePage_Tab1;
        }
        set
        {
            up_EntirePage_Tab1 = value;
        }
    }

有关TAB2在UserControl2

for Tab2 on UserControl2

     public UpdatePanel Tab2UpdatePanel
    {
        get
        {
            return up_EntirePage_Tab2;
        }
        set
        {
            up_EntirePage_Tab2 = value;
        }
    }

现在你拥有财产性两个UpdatePanel的,现在你可以使用它们,做任何你想做的事情。

Now you have property for both Updatepanel , Now you can use them and do whatever you want with it.

    protected void tabClick(object sender, RadTabStripEventArgs e)
    {

    if (e.Tab.SelectedIndex == 0)
    {
           UserControl1.Tab1UpdatePanel.Update();
    }
    else
    {
           UserControl2.Tab2UpdatePanel.Update();
    }
    }

这篇关于调用父页面的子控件的一个UpdatePanel的更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆