Updatepanel不从外部更新

时间:2012-11-14 15:52:05

标签: c# asp.net updatepanel

这听起来可能非常复杂,所以请留在我身边。

我有一个页面,我调用了一个更新面板,并根据客户端点击的表格行使用jQuery手动刷新。

这会显示一个新的更新面板。

这是按预期工作但我注意到它在点击后发出控制台错误 Uncaught TypeError: Cannot call method 'get_dataItems' of undefined ScriptResource.axd:5679

我尝试将更新模式设置为条件并从后面的代码中调用它,并尝试在更新面板上设置触发器,但收到cannot find control错误。

我也尝试过异步回发。

我想知道是否有人能想到可能的解决方案。

     <asp:UpdatePanel ID="ui_upnlCustomerTable" class="table-position" UpdateMode="Conditional"runat="server">
        <ContentTemplate> <asp:Panel ID="ui_pnlCustomerInfo" runat="server">
                <div class="content-header">
                    <p class="detail-header">
                        Scheme</p>
                </div>
                <div class="detail-form content-background">
                    <table class="schemes-table">
                        <thead>
                            <tr>
                                <th>
                                    text
                                </th>
                                <th>
                                    text
                                </th>
                                <th>
                                    Current Schemes
                                </th>
                            </tr>
                            <asp:Repeater ID="ui_rptCustomerDetails" OnItemDataBound="ui_rptCustomerDetails_ItemDataBound"
                                 runat="server">
                                <ItemTemplate>
                                    <asp:Label ID="ui_lblHdnMemno" Visible="false" runat="server" />
                                    <tr onmouseover="ChangeColor(this, true);" onmouseout="ChangeColor(this, false);"
                                        onclick="dosomething(memno)"
                                        style="cursor: pointer">
                                        <asp:LinkButton ID="ui_btnSelect" runat="server">
                                            <td>

                                            </td>
                                            <td>
                                                <
                                            </td>
                                            <td>
                                                <asp:Repeater ID="ui_rptSchemeNames" runat="server">
                                                    <ItemTemplate>
                                                        <
                                                    </ItemTemplate>
                                                </asp:Repeater>
                                            </td>
                                        </asp:LinkButton>
                                    </tr>
                                </ItemTemplate>
                            </asp:Repeater>
                        </thead>
                    </table>
                    <asp:Panel ID="ui_pnlInformation" runat="server">
                        <div style="font-size: 1.4em">
                            Please select either yourself or one of your friends or family in order to edit
                            or add schemes.
                        </div>
                    </asp:Panel>
                </div>
            </asp:Panel><asp:UpdatePanel ID="ui_pnlSchemeEncap" Visible="false" UpdateMode="Conditional" runat="server">
                <ContentTemplate>
                <asp:Label ID="ui_lblClickedCustomer" Visible="false" runat="server" />
                <asp:Panel ID="ui_pnlCurrentSchemesSlider" class="table-postition" runat="server"><div id="slider"><div id="schemeInformation" class="detail-form content-background">
                            <div class="content-header">
                                <p class="detail-header">Scheme Information</p>
                            </div>
                            <div>
                                <ul id="event-slider">
                                    <asp:Repeater ID="ui_rptCurrentSchemeSlider" OnItemCommand="ui_rptAssignedSchemes_ItemCommand"
                                        runat="server">
                                        <ItemTemplate>
                                            <li class="scheme-container" style="list-style: none;">
                                                <div class="scheme-slider-title">

                                                </div>
                                                <div class="scheme-image">
                                                </div>
                                                <div class="scheme-main-description">

                                                </div>
                                                <div class="scheme-slider-buttons">
                                                    <asp:LinkButton ID="ui_btnAddScheme" class="button" Style="font-size: 0.9em;" Text="Edit"
                                                        CommandName="Edit" CommandArgument='<%# Eval ("ID") %>' runat="server" />
                                                </div>
                                            </li>
                                        </ItemTemplate>
                                    </asp:Repeater>
                                    <asp:Repeater ID="ui_rptAssignedSchemesSlider" OnItemCommand="ui_rptAssignedSchemes_ItemCommand"
                                        runat="server">
                                        <ItemTemplate>
                                            <li class="scheme-container" style="list-style: none;">
                                                <div class="scheme-slider-title">

                                                </div>
                                                <div class="scheme-image">
                                                </div>
                                                <div class="scheme-main-description">

                                                </div>
                                                <div class="scheme-slider-buttons">
                                                    <div class="button-container-schemes">
                                                        <asp:LinkButton ID="ui_btnAddScheme" class="button" Style="font-size: 0.9em;" Text="Add"
                                                            CommandName="Add" CommandArgument='ID' runat="server" />
                                                    </div>
                                                </div>
                                            </li>
                                        </ItemTemplate>
                                    </asp:Repeater>
                                </ul>
                            </div>
                        </div>
                    </div>
                </asp:Panel>
                <div class="customer-names-container content-background">
                    <div style="padding: 10px">
                        <div class="content-header">
                            <p class="detail-header">
                                Customers
                            </p>
                        </div>
                        <div>
                            <asp:Repeater ID="ui_rptCustomerNames" OnItemCommand="ui_rptCustomerNames_ItemCommand"
                                runat="server">
                                <ItemTemplate>
                                    <asp:LinkButton ID="ui_lnkCustomerClick" CommandName="choice" CommandArgument='ID'
                                        runat="server">
                                        <asp:Panel runat="server" ID="ui_pnlCustomerSelection" Style="font-size: 1.4em; padding: 15px;
                                            width: 91%">
                                            <asp:Label ID="ui_hdnMemno" Text='id' Style="display: none" runat="server" />
                                            <asp:Label ID="ui_lblCustomerName" Text=''
                                                runat="server" />
                                        </asp:Panel>
                                    </asp:LinkButton>
                                </ItemTemplate>
                            </asp:Repeater>
                        </div>
                    </div>
                </div>
                <div class="scheme-info-container">
                    <asp:UpdatePanel ID="ui_updSchemeInfo" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <asp:Panel ID="ui_pnlCurrentSchemes" class="table-postition" runat="server">
                                <div class="scheme-form content-background">
                                    <div class="content-header">
                                        <p class="detail-header">
                                            Current Schemes
                                        </p>
                                    </div>
                                    <table class="table-standard" style="width: 355px">
                                        <thead class="scheme-list">
                                            <tr>
                                                <th>
                                                    Scheme Name
                                                </th>
                                                <th style="width: 100px">
                                                </th>
                                            </tr>
                                            <asp:Repeater ID="ui_rptCurrentSchemes" OnItemCommand="ui_rptAssignedSchemes_ItemCommand"
                                                runat="server">
                                                <ItemTemplate>
                                                    <tr>
                                                        <td>

                                                        </td>
                                                        <td style="width: 100px">
                                                            <div class="button-container-schemes">
                                                                <a id='scheme-select' class="button" style="font-size: 1em">More Info</a>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </ItemTemplate>
                                            </asp:Repeater>
                                        </thead>
                                    </table>
                                </div>
                            </asp:Panel>
                            <asp:Panel ID="ui_pnlAvailableSchemes" class="table-position" runat="server">
                                <div class="scheme-form content-background">
                                    <div class="content-header">
                                        <p class="detail-header">
                                            Available Schemes
                                        </p>
                                    </div>
                                    <table class="table-standard" style="width: 355px">
                                        <thead class="available-scheme-list">
                                            <tr>
                                                <th>
                                                    Scheme Name
                                                </th>
                                                <th style="width: 100px">
                                                </th>
                                            </tr>
                                            <asp:Repeater ID="ui_rptAssignedSchemes" OnItemCommand="ui_rptAssignedSchemes_ItemCommand"
                                                runat="server">
                                                <ItemTemplate>
                                                    <tr>
                                                        <td>
                                                            <%# Eval ("SchemeName") %>
                                                        </td>
                                                        <td style="width: 100px">
                                                            <div class="button-container-schemes">
                                                                <a id='scheme-select-idnum' class="button" style="font-size: 1em">More Info</a>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </ItemTemplate>
                                            </asp:Repeater>
                                        </thead>
                                    </table>
                                </div>
                            </asp:Panel>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </div>
                </ContentTemplate>
            </asp:UpdatePanel>
<div class="register-section">
            </div></ContentTemplate>
    </asp:UpdatePanel>

我必须删除一些信息,但页面结构是相同的。

public partial class controls_ctrSchemes : System.Web.UI.UserControl {
dll call clickedCustomer = new dll call;
protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        BindCustomer();
    }

    if (Request.Form["__EVENTTARGET"] != null)
    {
        string action = Request.Form["__EVENTTARGET"].ToString();
        if (action == "ctl00_ContentPlaceHolder1_ui_ctrAccount_ui_ctrSchemes_ui_upnlCustomerTable")
        {
            string name = Request.Form["__EVENTARGUMENT"].ToString();
            BindAllSchemes(name);
        }
    }
}

protected void ui_lnkBackButton_Click(object sender, EventArgs e)
{
    ui_pnlAvailableSchemes.Visible = false;
    ui_pnlCurrentSchemes.Visible = false;
    ui_pnlCurrentSchemesSlider.Visible = false;
    ui_pnlCustomerInfo.Visible = true;
    ui_upnlCustomerTable.Update();
    // Response.Redirect("account.aspx");
}

protected void ui_rptCustomerDetails_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
    if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
    {
        Repeater ui_rptSchemeNames = (Repeater)e.Item.FindControl("ui_rptSchemeNames");
        Label ui_lblHdnMemno = (Label)e.Item.FindControl("ui_lblHdnMemno");

        Intascape.Library.Customer.Customer customer = new Intascape.Library.Customer.Customer();
        customer.memno = Convert.ToInt32(ui_lblHdnMemno.Text);
        customer.Load();

        ui_rptSchemeNames.DataSource = customer.CustomerSchemes;
        ui_rptSchemeNames.DataBind();
    }
}

protected void ui_rptCustomerNames_ItemCommand(object sender, RepeaterCommandEventArgs e)
{
    ui_updSchemeInfo.Update();
    if (e.CommandName == "choice")
    {
        int memno = Convert.ToInt32(e.CommandArgument);
        clickedCustomer.memno = memno;
        clickedCustomer.Load();

        if (clickedCustomer.CustomerSchemes.Count() != 0)
        {
            BindCurrentSchemes(clickedCustomer);
            ui_pnlCurrentSchemes.Visible = true;
            BindAvailableSchemes(clickedCustomer);
        }
        else
        {
            //BindAvailableSchemes(clickedCustomer);
            //ui_pnlCurrentSchemes.Visible = false;
            ui_pnlCurrentSchemes.Attributes.Add("style", "display: none");
            ui_pnlAvailableSchemes.Visible = false;
        }
        ui_upnlCustomerTable.Update();
    }
}

protected void ui_rptAssignedSchemes_ItemCommand(object sender, RepeaterCommandEventArgs e)
{
    switch (e.CommandName)
    {
        case ("Add"):
            int schemeID = Convert.ToInt32(e.CommandArgument);
            Intascape.Library.Customer.CustomerSchemesCollection schemes = clickedCustomer.CustomerSchemes;
            foreach (Intascape.Library.Customer.CustomerSchemes scheme in schemes.Where(x => x.schemeID == schemeID))
            {
                if (scheme.SchemePaymentType == "System")
                {
                    //show card capture
                }
                else
                {
                    //show direct debit
                }
            }
            break;
        case ("Edit"):
            break;

        case ("info"):
            break;
    }
}

private void BindCustomer()
{
    List<dll> customerList = new List<dll>();
    customerList.Add(SessionHelper.Customer);
    customerList.AddRange(SessionHelper.Customer.FriendsAndFamily);
    ui_rptCustomerDetails.DataSource = customerList;
    ui_rptCustomerDetails.DataBind();
    ui_rptCustomerNames.DataSource = customerList;
    ui_rptCustomerNames.DataBind();
}

private void BindAvailableSchemes(dll clickedCustomer)
{
    //clear repeater
    if (ui_rptAssignedSchemes.DataSourceID != null)
    {
        ui_rptAssignedSchemes.DataSourceID = null;
        ui_rptAssignedSchemes.DataSource = null;
    }
    ui_rptAssignedSchemes.DataSource = clickedCustomer.AvailableCustomerSchemes;
    ui_rptAssignedSchemesSlider.DataSource = clickedCustomer.AvailableCustomerSchemes;

    //bind data
    ui_rptAssignedSchemes.DataBind();
    ui_rptAssignedSchemesSlider.DataBind();
}

private void BindCurrentSchemes(dll clickedCustomer)
{

    if (ui_rptCurrentSchemes.DataSourceID != null)
    {
        ui_rptCurrentSchemes.DataSourceID = null;
        ui_rptCurrentSchemes.DataSource = null;
    }
    //in here do the reapeater to add the schemes the customer has currently assigned themseleves to to allow edit
    //of payment
    ui_rptCurrentSchemes.DataSource = clickedCustomer.CustomerSchemes;
    ui_rptCurrentSchemeSlider.DataSource = clickedCustomer.CustomerSchemes;
    ui_rptCurrentSchemes.DataBind();
    ui_rptCurrentSchemeSlider.DataBind();
}

private void BindAllSchemes(string memno)
{
    clickedCustomer.memno = Convert.ToInt32(memno);
    clickedCustomer.Load();
    if (clickedCustomer.CustomerSchemes.Count() != 0)
    {
        BindCurrentSchemes(clickedCustomer);
        BindAvailableSchemes(clickedCustomer);
        ui_pnlCustomerInfo.Visible = false;
        //ui_pnlSchemeEncap.Attributes["style"] = "display:none;";
        ui_pnlSchemeEncap.Visible = true;
    }
    else
    {
        BindAvailableSchemes(clickedCustomer);

        ui_pnlCurrentSchemes.Visible = false;
        //ui_pnlSchemeEncap.Attributes["style"] = "display:none;";
        ui_pnlSchemeEncap.Visible = true;
    }

    foreach (RepeaterItem item in ui_rptCustomerNames.Items)
    {

        Label custMemno = (Label)item.FindControl("ui_hdnMemno");
        if (Convert.ToInt32(custMemno.Text) == clickedCustomer.memno)
        {
            Panel div = (Panel)item.FindControl("ui_pnlCustomerSelection");
            div.Attributes.Add("class", "chosen");
        }
    }
}}

再次不得不删除一些主要是dll调用。

任何进一步的问题,请告诉我

0 个答案:

没有答案