1

在我的子页面中,我有一个 imageButton,它被 UpdatePanel 包围。当用户单击图像按钮时,会从我的数据库中删除一条记录。

<asp:Content ID="Content1" ContentPlaceHolderID="Content" runat="server">
 <asp:UpdatePanel ID="UpdatePanel1" runat="server">
 <Triggers><asp:AsyncPostBackTrigger ControlID="btnRemove" /></Triggers>
    <ContentTemplate>
            <asp:ListView ID="ListView2" runat="server">
                <layouttemplate>
                    <asp:PlaceHolder id="itemPlaceholder" runat="server" />
                </layouttemplate>
                <ItemTemplate>
                  <asp:ImageButton ID="btnRemove" runat="server" CommandName='<%# DataBinder.Eval(Container.DataItem, "ID") %>'/></ItemTemplate>
            </asp:ListView>
 </ContentTemplate>
 </asp:UpdatePanel>
</asp:Content>

在我的母版页中,我有文字控制,可以显示当前用户的记录(类似于Records: 10

RecordsCount 控件在 MasterPage 的页面 Load 事件上更新

 Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      RecordsCount.Text = GetRecordsCount()
 End Sub 

所以这是我的问题

  1. 如何更新RecordsCount控件?我的意思是我使用回发从数据库中删除记录。目前,如果用户点击 Internet 浏览器的 Refresh 按钮,RecordsCount 控件将被更新。
  2. 当用户单击子页面上的按钮时,我如何在控件上应用Jquery Highlight ?RecordsCountbtnRemove

更新:第一个问题是通过使用javascript解决的

4

2 回答 2

1

这听起来像是一个糟糕的布局。

母版页不应该负责显示数据页特定的数据。相反,它只是为各种内容面板提供布局和“漏洞”,以便页面可以插入数据/控件。

我会从母版页中删除它并添加一个新的内容面板以允许页面显示数据。然后在您的页面中,添加记录数或您想要的任何其他内容。

于 2011-03-11T18:30:46.223 回答
-1

好吧,听起来我有一个幸福的结局!

RecordsCount 控件使用 javascript 更新,而 (Attribute Ends With Selector) Jquery 通过这篇文章成功应用

<script type="text/javascript">
        $(document).ready(function () {
            $('input[id$="btnFavorite"]').click(function () { $('#Favorite').effect('highlight', { color: '#AAAAAA' }, 3000); }
        });
</script>
于 2011-03-12T18:33:30.603 回答