更新母版页上的文字控件
在我的子页面中,我有一个 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
所以这是我的问题
- 如何更新
RecordsCount
控件? 我的意思是我使用回发从数据库中删除记录。目前,如果用户点击 Internet 浏览器的“刷新”按钮,RecordsCount 控件将会更新。 - 我如何在
RecordsCount
控件上应用 Jquery 高亮用户单击子页面上的btnRemove
按钮?
更新:第一个问题是通过使用 javascript 解决的
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.DataItem, "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
- 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. - How could i apply the Jquery Highlight on the
RecordsCount
control when the user clicks on thebtnRemove
button on the child-page?
UPDATE: Well the first question is solved by using javascript
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这听起来像是一个做得很糟糕的布局。
母版页不应负责显示数据页特定数据。相反,它只是简单地提供布局和带有各种内容面板的“孔”,以便页面可以插入数据/控件。
我会将其从母版页中删除并添加一个新的内容面板以允许页面显示数据。然后在您的页面中添加记录计数或您想要的任何其他内容。
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.
嗯,听起来我有一个幸福的结局!
RecordsCount 控件使用 JavaScript 进行更新,而(属性以选择器结尾)Jquery 已通过此 帖子 成功应用
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