0

I am creating a custom serve control (extends composite control). I want this control to use update panels but I think it would be best to require the user to place my control within their own update panels, instead of me coding it into my control. My question is two part:

  1. How do I alert the developer who is using my control that they are required to put the control in an update panel

  2. In my server code, how do I get a handle on the update panels ID that the user control is inside of?

Thanks for any insight.

Edit: here is how I have my code setup:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
   <ContentTemplate>   
      <cc3:myServerControl id="activerDirectorySearch1" runat="server"  />
   </ContentTemplate>
</asp:UpdatePanel>

so, because my user control cannot know what the udpate panel is named (and I dont want to hard code it) I would like to find a way for the server control to get its parents ID. But, if I use parent.id I just get the web pages name returned.

jason

jason
  • 3,821
  • 10
  • 63
  • 120

1 Answers1

0
  1. You can expose public property UpdatePanelID from your control.

  2. If user doesn't provider that UpdatePanelID, throw exception.

Same idea is used in ASP.Net ListView's ContentPlaceHolderID

Win
  • 61,100
  • 13
  • 102
  • 181
  • Thanks for the response. I was hoping there was a way to get the updatepanel programatically to eliminate user errors, if possible. You're right, though. If I get the ID, i could try to cast using that ID and throw as custom exception if it fails – jason Mar 14 '13 at 14:21
  • Actually, I don't even think I could ask the user for the updatepanel id as .Net assigns these controls unique id's that the user may not know. IE: they might title the UP as "UpdatePanel1" but in reality the name might be: UserControl1_UpdatePanel – jason Mar 14 '13 at 14:23
  • `ListView`'s `ContentPlaceHolderID` was set at design time. See its source code. – Win Mar 14 '13 at 14:31