MultiView中的事件处理程序

时间:2013-08-02 09:19:15

标签: c# asp.net .net postback multiview

我倾向于使用MultiViews,我看到了一个我从未遇到过的奇怪问题。仅对第一个Multiview索引或其外部的控件将导致其附加的事件处理程序被触发。 MultiView位于UserControl内。

我可以更改MultiView索引,但0以外的任何索引中的任何控件都不会触发事件处理程序。是否有任何合理的原因可以调试它?

我的MultiView被声明为

    <asp:Button ID="btnPostTopicAlsoWorking" runat="server" Text="Post Topic" CssClass="button" ValidationGroup="post" OnClick="btnPostTopic_Click"/>
<asp:MultiView runat="server" ID="mltMain" ActiveViewIndex="0" OnActiveViewChanged="viw_Changed">
    <asp:View runat="server" ID="viwCategories">
        ...this works
        <asp:Button ID="btnPostTopic" runat="server" Text="Post Topic" CssClass="button" ValidationGroup="post" OnClick="btnPostTopic_Click"/>
    </asp:View>
    <asp:View runat="server" ID="viwCategorySingle">
        ...this does not work
        <asp:Button ID="btnPostTopicBroken" runat="server" Text="Post Topic" CssClass="button" ValidationGroup="post" OnClick="btnPostTopic_Click"/>

1 个答案:

答案 0 :(得分:0)

这是追踪的噩梦。 UC嵌入在Umbraco页面中,UC添加了宏。如果我创建一个MasterPage并包含这样的宏:

<%@ Master Language="C#" MasterPageFile="~/masterpages/umbMaster.master" AutoEventWireup="true" %>

<asp:Content ID="Content2" ContentPlaceHolderID="cp_content" runat="server">
    <umbraco:Item ID="Item1"  runat="server" field="bodyText" />
</asp:Content>

我可以创建一个Umbraco页面,使用编辑器插入宏,它将显示并且功能正常。为了让它按预期工作,我需要将宏直接嵌入MasterPage:

<asp:Content ID="Content2" ContentPlaceHolderID="cp_content" runat="server">
    <umbraco:Macro ID="Macro1" runat="server" Alias="forumCategoryFrontEnd"/>
</asp:Content>