AJAX Update Panel and ASP Panel

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Marknut
    New Member
    • Apr 2010
    • 42

    #1

    AJAX Update Panel and ASP Panel

    I have an AJAX UpdatePanel that contains multiple dropdownlists, a button, and an ASP Panel (which contains dropdownlists and textboxes). On button_click I want to enable the ASP panel, but it is not enabling. The ddls all work fine, I just can't enable/disable any controls within the update panel or the asp panel itself.
    • I tried UpdateMode = Always
    • I tried UpdateMode = Conditional where ddls and button were triggers
    • I tried adding UpdatePanel.Upd ate() to the button_click
    • I tried using visible instead of enabled (ASP Panel)

    Nothing is working. Side Note: this is all within a step on the ASP Wizard (maybe that's the issue?).
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Well I tried it and it worked fine for me.

    I used a Wizard Control, placed an UpdatePanel within it...and within the UpdatePanel I have a Panel and 2 buttons (enable and disable). Within the Panel I have a DropDownList and a CheckBox.

    In the enable button click event I enable the panel...in the disable button click event I disable the panel.

    Everything works fine within the UpdatePanel within the Wizard.

    This is what I have in my ASP page markup:
    Code:
    <asp:Wizard ID="theWiz" runat="server">
        <WizardSteps>
            <asp:WizardStep ID="step1" runat="server">
                <asp:UpdatePanel ID="Update1" runat="server">
                    <ContentTemplate>
                        <asp:Panel ID="aPanel" runat="server" Enabled="false">
                            <asp:DropDownList ID="aDDL" runat="server">
                                <asp:ListItem Text="1" Value="1"></asp:ListItem>
                                <asp:ListItem Text="2" Value="2"></asp:ListItem>
                                <asp:ListItem Text="3" Value="3"></asp:ListItem>
                            </asp:DropDownList>
                            <asp:CheckBox ID="someCheckbox" runat="server" Text="Check Box..." />
                        </asp:Panel>
                        <asp:Button ID="enableButton" runat="server" Text="Enable" />
                        <asp:Button ID="disableButton" runat="server" Text="Disable" />
                    </ContentTemplate>
                </asp:UpdatePanel>
            </asp:WizardStep>
        </WizardSteps>
    </asp:Wizard>
    This is what I have in my server-side code (VB.NET):
    Code:
    Public Partial Class Test
        Inherits System.Web.UI.Page
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
        End Sub
       
        Private Sub enableButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles enableButton.Click
            aPanel.Enabled = True
        End Sub
    
        Private Sub disableButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles disableButton.Click
            aPanel.Enabled = False
        End Sub
    End Class

    I recommend that you step through your code and discover where you are setting the Panel.Enabled to false after you set it to true.

    -Frinny
    Last edited by Frinavale; Aug 31 '10, 07:39 PM.

    Comment

    • Marknut
      New Member
      • Apr 2010
      • 42

      #3
      Thanks for the quick response! What's wierd is when I place a message box on eiher side of the panel.enabled=t rue, I get the correct values. "False" before the enabled statement and "True" after. Then,when I click the button again, the exact same thing. "False" then "True." And I have no other code that ever disables the panel. Any ida what might cause that?

      Comment

      • Marknut
        New Member
        • Apr 2010
        • 42

        #4
        Also, your code works great for me, I'm not sure what's happeneing with mine. There's a lot of wizard code or else I would paste it.

        Comment

        • Marknut
          New Member
          • Apr 2010
          • 42

          #5
          The answer is that I'm getting an error with my cascading dropdownlists. The error shows at the bottom of the page, doing virtually nothing and appearing insignificant. Thanks to your example I noticed that I could not get yours to work after that error either so I need to investigate taht issue. Thanks for your help!

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            What is the error?

            Comment

            • Marknut
              New Member
              • Apr 2010
              • 42

              #7
              The error was "DropDownList_C lient selection is not valid because it is not in the list." It was my mistake, here's the code (which later assigns these variables to the corresponding dropdownlists):
              Code:
              If DropDownList_Site.SelectedValue <> "" Then 
                Site = DropDownList_Site.SelectedValue
              If DropDownList_Client_Parent.SelectedValue <> "" Then 
                Client_Parent = DropDownList_Client_Parent.SelectedValue
              End If
              If DropDownList_Client.SelectedValue <> "" Then 
                Client = DropDownList_[B][I]Site[/I][/B].SelectedValue
              End If
              If DropDownList_Program.SelectedValue <> "" Then 
                Program = DropDownList_Program.SelectedValue
              End If
              If DropDownList_Project.SelectedValue <> "" Then 
                Project = DropDownList_Project.SelectedValue
              End If
              The issue was the third line down. I would assign the Client variable the Site selection code. Then in DropDownList_Cl ient_databound, I would assign the Client variable to DropDownList_Cl ient.SelectedVa lue. The Problem was that I assigned the DropDownList_Si te.SelectedValu e to the Client variable. Here's the fixed code:
              Code:
              If DropDownList_Client.SelectedValue <> "" Then 
                Client = DropDownList_[I][B]Client[/B][/I].SelectedValue
              End If
              Last edited by Frinavale; Aug 31 '10, 08:00 PM. Reason: Formatted code so that it is valid and easier to read.

              Comment

              • Frinavale
                Recognized Expert Expert
                • Oct 2006
                • 9749

                #8
                :) I'm glad you fixed the problem :)

                -Frinny

                Comment

                Working...