Composite Control with DropDownList loses items after Postback

Last post 07-29-2009 7:17 AM by kallem. 1 replies.

Sort Posts:

  • Composite Control with DropDownList loses items after Postback

    07-28-2009, 7:51 AM
    • Member
      2 point Member
    • kallem
    • Member since 02-22-2007, 4:36 AM
    • Posts 3

    Hi,

    I'm creating a composite control which should be called from aspx/ascx like the following:

    <ws:ExtendedLabel ID="lab_name" Text="Name" PopupText="Enter your name here" runat="server"
                IsMandatory="true">
                   <asp:TextBox ID="tb_name" runat="server" Text="" />
    </ws:ExtendedLabel>

    So, the Label should be rendered, together with an mandatory-sign and small tooltip popping up when mouseover is active. Additionally, the TextBox should be associated to the label and rendered.

    For that I created a UserControl, derived from Label. I use the [ParseChildren(false)]-Property.

    In CreateChildControls() I add the Link for the tooltip-layer and the tooltip itself. I also override the RenderChildren-function to add some html before/after rendering the textbox.

    This works fine, even after Postback everything works as espected.

    If I want to use a DropDownList instead of a TextBox, the DropDownList loses their items. After some websearch I think this is a viewstate-problem, but I don't know how to solve it.

    Any help?


    I tried to describe the problem and didn't posted the complete source-code to leave this post slim.

    Cheers, kalle.

  • Re: Composite Control with DropDownList loses items after Postback

    07-29-2009, 7:17 AM
    Answer
    • Member
      2 point Member
    • kallem
    • Member since 02-22-2007, 4:36 AM
    • Posts 3

    So, after some more tries I decided to go another way.

    The ExtendedLabel will only render the label, the mandatory sign and the help popup. This works.

    I'll leave the controls outside the ExtendedLabel, because I'm afraid of more side effects.



    Cheers, kalle. 

Page 1 of 1 (2 items)