2

I have 2 pages each with an update panel. It has the same content and the same trigger on both pages.

This is how it looks:

                     <div id="rating">
                    <span class="rateTxt">Rate</span>
                    <telerik:RadRating ID="RadRating1" runat="server" ItemCount="5" SelectionMode="Continuous"
                        Precision="Item" Skin="Default" OnRate="RadRating1_Rate" AutoPostBack="true">
                    </telerik:RadRating>
                 </div>
            </li>
         </ul>
            <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                <ContentTemplate>
                    <div id="divAddMessage" runat="server" visible="false">
                        <span class="rateTxt">Do you want to add a comment?</span>
                        <asp:TextBox runat="server" ID="txtComment" TextMode="MultiLine" Rows="3" Width="195">
                        </asp:TextBox>
                        <br />
                        <br />
                        <asp:ImageButton runat="server" ID="lnkAddComment" ImageUrl="~/App_Themes/123reg/Images/submit-rating.png"
                            OnClick="lnkAddComment_Click" OnClientClick="showSuccessMessage();" />
                        <br />
                        <br />
                    </div>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="RadRating1" EventName="Rate" />
                </Triggers>
            </asp:UpdatePanel>

Now when the user rates something with the RadRating the Rate event is triggered which causes a postback.

On the handler for the Rate event I do the following:

    protected void RadRating1_Rate(object sender, EventArgs e)
    {
        divAddMessage.Visible = true;
    }

The same code is exactly on 2 pages. On one page it updates the divAddMessage and it becomes visible but on another page it doesn't become visible. Even if I set it to visible on that page when it postback again the Visible property is still false even after setting it to true in the above handler.

I only set the visibily to false in the aspx file and in the above handler I set it to true.

It turns out that I get an error in the javascript console:

Sys.InvalidOperationException: Sys.InvalidOperationException: Could not find UpdatePanel with ID 'ctl00_mainContentPlaceHolder_updatePanel'. If it is being updated dynamically then it must be inside another UpdatePanel.

I have another update panel inside a multiview. But because the active view is not the one with the update panel on postback the update panel isn't rendered.

4

2 回答 2

3

检查父/容器元素的divAddMessage. 他们是否将其可见性设置为 false。如果是这样,那么Visible=false即使您已将其显式设置为 true,子元素也将始终存在。过去这让我发疯。

只是一个想法

于 2013-07-02T11:37:51.770 回答
0

我有一个自定义控件,并在 aspx 文件中的声明时将 Visible 属性设置为 false,这会覆盖控件本身内任何子元素的可见性。

于 2013-10-04T14:01:38.223 回答