回发后刷新母版页上的控件
我在这里尝试做的是以项目符号列表的形式显示一些验证消息,因此我的母版页上有一个包含 asp:bulletlist 的 Div。像这样:
<div>
<asp:BulletedList ID="blstValidationErrorMessage" runat="server" BulletStyle="Disc">
</asp:BulletedList>
</div>
当我从任何页面(在主要 contentPlaceHolder 内)单击“保存”按钮时,我创建一个消息列表并将该列表作为数据源提供,如下所示:
blstValidationErrorMessage.DataSource = validationMessageCollection;
blstValidationErrorMessage.DataBind();
“保存”按钮位于更新面板内:
asp:UpdatePanel runat="server" ID="UpdatePanel" ChildrenAsTriggers="true" UpdateMode="Conditional">
什么也没有发生,我可以看到项目符号列表的数据源包含 X 个项目,一定会出现问题,因为“保存”按钮位于更新面板内部,并且此更新面板外部的元素(例如母版页控件)未刷新。
所以我的问题是,如何使项目符号列表在回发后刷新?
提前致谢。
What i am trying to do here is to show a couple of validation messages in form of a bulletlist, so i have a Div on my master page containing a asp:bulletlist. Like this:
<div>
<asp:BulletedList ID="blstValidationErrorMessage" runat="server" BulletStyle="Disc">
</asp:BulletedList>
</div>
When i then click the Save button from any of my pages (inside the main contentPlaceHolder) i create a list of messages and give this list as datasouce like this:
blstValidationErrorMessage.DataSource = validationMessageCollection;
blstValidationErrorMessage.DataBind();
The save button is located inside an updatepanel:
asp:UpdatePanel runat="server" ID="UpdatePanel" ChildrenAsTriggers="true" UpdateMode="Conditional">
Nothing happens, i can see that the datasource of the bulletlist contains X items, the problems must arise because the Save button is inside an update panel and the elements outside this updatepanel (master page controls for example) is not refreshed.
So my question is, how do i make the bulletlist refresh after the postback?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Save 按钮只会更新您放置它的 UpdatePanel 的内容。我建议这样做:
The Save button will only update the contents of the UpdatePanel you placed it in. Here's what I recommend doing:
如果您的按钮位于 UpdatePanel 内,则也应将 BulletedList 控件放置在 UpdatePanel 内。
您可以在 MasterPage 文件中围绕 BulletedList 放置一个 UpdatePanel。将“UpdateMode”设置为“Conditional”,然后调用 UpdatePanel 的 Update 方法仅在需要时刷新(例如单击“保存按钮”)。
If your button is inside an UpdatePanel, you should place your BulletedList control inside an UpdatePanel too.
You can place an UpdatePanel surrounding the BulletedList in the MasterPage file. Set "UpdateMode" to "Conditional" then call the Update method of the UpdatePanel to refresh only when needed ('save button' click for example).