【问题标题】:could not be found for the trigger in UpdatePanel在 UpdatePanel 中找不到触发器
【发布时间】:2013-08-31 07:34:57
【问题描述】:

我需要将按钮保留在用户控件 (.ascx) 文件中。我已经为同一个按钮提供了 AsyncPostBackTrigger controlid。但在 UpdatePanel 中找不到触发器显示“错误”。任何人都可以帮助我吗? 这个我给了controlid

    <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">



    <ContentTemplate>

   <asp:Panel ID="pnlYourAccount" runat="server" Style="display: none; height: 100%;
      margin-left: 330px; margin-top: -230px;">

   here is my design

   </asp:Panel>

   </<ContentTemplate>

   </asp:UpdatePanel>

`

<Triggers>

<asp:AsyncPostBackTrigger ControlID="btn1" EventName="Click" />

</Triggers>

`

我保存在用户控件中的这个链接按钮(用于顶部菜单)。当点击菜单时,内容应该得到更新

<asp:LinkButton class="anchorstyle" ID="btn1" runat="server" Text="MenuName" />

【问题讨论】:

  • 请出示一些代码。
  • 请指定一些代码
  • 请在此处发布您的代码。
  • 我已经给出了一些代码部分
  • 添加点击事件aspx ane cs页面然后使用。

标签: asp.net


【解决方案1】:

在 aspx 页面中

<asp:LinkButton class="anchorstyle" ID="btn1" runat="server" Text="MenuName" OnClick="btn1_Click" />

在 aspx.cs 页面中添加此事件

protected void btn1_Click(object sender, EventArgs e)
{
   //write your code here
}

然后它工作正常。

【讨论】:

  • 是的,我已经从 aspx 页面中删除了触发器。现在添加通过 aspx.cs 页面。
  • 如何在 aspx 页面中访问用户控件的控件(链接按钮)。
  • 那么你有什么问题吗?
  • 你为什么得到这个控件。在链接按钮点击事件上你还想要什么?
  • 是的。我想设置 AsyncPostBackTrigger 触发器; trigger.ControlID = "这里我要设置链接按钮的id";
猜你喜欢
  • 2011-10-03
  • 2012-08-21
  • 1970-01-01
  • 1970-01-01
  • 2011-01-16
  • 2013-08-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多