Re: Nested UpdatePanel Question

Discussion in 'ASP .Net' started by Gregory A. Beamer, Jul 15, 2009.

  1. Daniel <> wrote in
    news:4a5dff3e$0$3874$:

    > Hi,
    >
    > I am attempting to make a control visible based on a listbox's
    > selectedindexchanged event.
    >
    > I have an panel -> updatepanel that contains a listbox. Nested inside
    > the updatepanel, I have a panel with some controls on it. What I am
    > attempting to do is: When the user selects an item in the listbox, the
    > panel (and the controls on it) become visible. I want to ensure that
    > the user has made a choice from the listbox before allowing them to
    > enter any other data. In the code behind, in the
    > lstClasses_SelectedIndexChanged event, I simply do a
    > Panel1.visible=true, but no joy!! Anybody have an idea of how I can
    > get this to work???
    >
    > Here is the relevant aspx code:
    >
    > <asp:panel ID="pnlAddPT" runat="server" style="display: none">
    > <asp:UpdatePanel ID="UpdatePanel1" runat="server"
    > ChildrenAsTriggers="false" UpdateMode="Conditional">
    > <ContentTemplate>
    > <div class="HellowWorldPopup">
    > <div class="PopupHeader" id="PopupHeader">Add A New
    > Patient</div> <div class="PopupBody">
    > <p>Double Click to Select a Class</p>
    > </div>
    > <div style="padding-left:30px;">
    > <asp:ListBox ID="lstClasses" runat="server"
    > OnSelectedIndexChanged="lstClasses_SelectedIndexCh

    a
    > nged" />
    > </div>
    > <asp:UpdatePanel ID="UpdatePanel2" runat="server"
    > ChildrenAsTriggers="false" UpdateMode="Conditional">
    > <ContentTemplate>
    > <asp:panel ID="Panel1" runat="server" Visible="false">
    >
    > <asp:Label ID="Label4" runat="server" Text="Assignment Date:"
    > />
    > <asp:Calendar ID="Calendar1" runat="server"
    > Caption="Assignment Date:"
    > CaptionAlign="Top" Height="50px"
    > Width="75px"></asp:Calendar>
    > <asp:Label ID="Label2" runat="server" Text="First
    > Initial:" />
    > <asp:TextBox ID="txtFinitial"
    > runat="server"></asp:TextBox> <asp:Label ID="Label3"
    > runat="server" Text="Last Initial:" /> <asp:TextBox
    > ID="txtLinitial" runat="server"></asp:TextBox>
    > <br />
    > </asp:panel>
    > </ContentTemplate>
    > <Triggers>
    > <asp:AsyncPostBackTrigger ControlID="lstClasses"
    > EventName="SelectedIndexChanged" /> </Triggers>
    > </asp:UpdatePanel>
    >
    >
    > Any help is greatly appreciated!!!
    >


    Okay, so you want Panel1 to become visible with the information pulled
    from AJAX, right? I am going to assume so unless you write back to state
    otherwise.

    Let's run through what you are trying to do, as I read this:

    1. user chooses item other than blank (or "choose item")
    2. AJAX call made to get data for second update panel
    3. Panel is made visible

    You are attempting to do both 2 and 3 on the server side, as near as I
    can tell, as you are trying to do it in SelectedIndexChanged. Is this
    clicking?

    You made an AJAX call (server side) and you want to change the client.
    Clearer?

    The answer is you are doing something server side (getting data to fill
    the region) and something client side (showing the panel). The client
    side bits cannot be accomplished server side without refreshing the page
    (non AJAX call).

    So, to solve the panel bit, you can attach to a client side event, as
    well, and emit the code to show the panel (toggle type code).

    If the calendar was not there, I would say you could simply fill the
    controls with an empty data set, but the calendar pretty much munges
    that.

    If I am off track, post back.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA

    Twitter: @gbworld
    Blog: http://gregorybeamer.spaces.live.com

    *******************************************
    | Think outside the box! |
    *******************************************
    Gregory A. Beamer, Jul 15, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    479
    Rob Meade
    Aug 8, 2007
  2. Replies:
    1
    Views:
    411
    Braulio Diez
    Dec 11, 2007
  3. Clodoaldo
    Replies:
    0
    Views:
    3,464
    Clodoaldo
    Jan 30, 2008
  4. MU
    Replies:
    2
    Views:
    10,871
    gerry
    Jan 14, 2009
  5. Nathan Sokalski
    Replies:
    1
    Views:
    588
    miher
    Jun 15, 2009
Loading...

Share This Page