开发者

Couldn't find updatepanel inside hidden div

I have an Updatepanel inside hidden Div, but I am getting "Could not find UpdatePanel with ID 'ctl00_ContentPlaceHolder_ctl04_UpdatePanel1'. I am trying to show and hide this panel from code behind. Thanks for any help. Here is my code.

<div id="div1" runat="server" style="display:none">
  <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
            <table id="Table1">
               <tr>
                  <td>
                    <telerik:RadComboBox ID="RadComboBox1" runat="server"
                                        AutoPostBack="true" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">
                   </开发者_如何学Pythontelerik:RadComboBox>
                  </td>
                  <td valign="top">
                     <asp:Button ID="button1" runat="server" OnClick="button1_Click" Text="Test1"
                                        /><br />
                     <asp:Button ID="button2" runat="server" OnClick="button2_Click" Text="Test2"
                                         />
                  </td>
                            </tr>
            </table>
    </ContentTemplate>
 </asp:UpdatePanel>
</div>


you can only manipulate the the code inside the ContentTemplate from the updatepanel's postbacks, so the "div1"s display property can't be changed by the updatepanel's postbacks.
you could move the div inside the updatepanel and then it should work

I'd try this:

  <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Panel runat="server" id="div1" runat="server" style="display:none">
            <table id="Table1">
               <tr>
                  <td>
                    <telerik:RadComboBox ID="RadComboBox1" runat="server"
                                        AutoPostBack="true" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">
                   </telerik:RadComboBox>
                  </td>
                  <td valign="top">
                     <asp:Button ID="button1" runat="server" OnClick="button1_Click" Text="Test1"
                                        /><br />
                     <asp:Button ID="button2" runat="server" OnClick="button2_Click" Text="Test2"
                                         />
                  </td>
                            </tr>
            </table>
<asp:Panel>
    </ContentTemplate>
 </asp:UpdatePanel>

Keep in mind the client id of div1 will no longer be div1 (unless your using .net 4 in which case you can specify that it is'div1') you can fix this a variety of ways but basically you just need to add a little bit of javascript to the page that associates the actual WebControl.ClientID with 'div1'.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜