开发者

Updating a literal control on a master page

In my child page i have an imageButton, which is surrounded by the UpdatePanel. When the user clicks on the image button a record is removed from my database.

<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.DataI开发者_开发问答tem, "ID") %>'/></ItemTemplate>
            </asp:ListView>
 </ContentTemplate>
 </asp:UpdatePanel>
</asp:Content>

In my master page i have literal control which displays the records for the current user (something like Records: 10)

The RecordsCount control is updated on the page Load event of the MasterPage

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

So here are my questions

  1. How can i update the RecordsCount control? I mean i use postbacks for removing records from the database. And currently the RecordsCount control will be updated if the user hits the Refresh button of the Internet browser.
  2. How could i apply the Jquery Highlight on the RecordsCount control when the user clicks on the btnRemove button on the child-page?

UPDATE: Well the first question is solved by using javascript


This sounds like a badly done layout.

The master page should NOT be responsible for displaying data page specific data. Instead it is there to simply provide the layout and "holes" with various content panels so the pages can plug in data / controls.

I'd rip that out of the master page and add a new content panel to allow the pages to display the data. Then in your page, add the record count or whatever else you want.


Well it sounds like i have had a happy end!

The RecordsCount control is updated with javascript while the (Attribute Ends With Selector) Jquery was applied successfully via this post

<script type="text/javascript">
        $(document).ready(function () {
            $('input[id$="btnFavorite"]').click(function () { $('#Favorite').effect('highlight', { color: '#AAAAAA' }, 3000); }
        });
</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜