【问题标题】:Eventhandlers in a MultiView多视图中的事件处理程序
【发布时间】:2013-08-02 09:19:14
【问题描述】:

我经常使用 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"/>

【问题讨论】:

  • 是否意味着所有按钮都应该使用相同的事件处理程序?
  • 不,它们实际上都是不同的,我已经将它们更改为相同的调试。
  • 调试的时候,还要检查ActiveViewIndex你的multiview有什么,看看是不是正确的。

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


【解决方案1】:

这是一场噩梦。 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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-18
    相关资源
    最近更新 更多