开发者

Refresh a control on the master page after postback

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:Bulle开发者_运维技巧tedList>
            </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.


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).


The Save button will only update the contents of the UpdatePanel you placed it in. Here's what I recommend doing:

  1. Move the SaveButton outside of the UpdatePanel. Where you put it I'll leave up to you.
  2. Put your validation div inside another UpdatePanel. Call it ValidationUpdatePanel
  3. Add your SaveButton as an AsyncPostbackTrigger for both update panels. Since you may have each UpdatePanel separated into different controls/pages, you'll probably want to do this in the code-behind programmatically.
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜