CascadingDropDown and Master Pages

Last post 11-12-2009 11:55 AM by jwriggs. 2 replies.

Sort Posts:

  • CascadingDropDown and Master Pages

    11-10-2009, 5:30 PM
    • Member
      6 point Member
    • jwriggs
    • Member since 04-22-2009, 4:16 PM
    • Posts 23

    Hi,

    I've been playing around with the cascadingdropdown control and am experiencing a problem that I hope someone can shed some light on.

    I created a solution without a master page in which the control works exactly as I would like it to. The user makes three selections, and based on those selections, the text of a label is filled in. Additionally, the dropdownlists are in an updatepanel so that the experience is better for the user.

    I took that code and tried to place it into another solution, but it no longer works. The dropdownlists still populate, but when the user makes the third choice, the label's text doesn't populate. Also, with each choice, it looks as though there's a postback, meaning that the updatepanel is being ignored.

    The code is now within a contentplaceholder, and so I'm wondering if there is some issue with master pages and the cascadingdropdown control. Has anybody seen this issue before? I'll post code if it's needed.

    thx

     

  • Re: CascadingDropDown and Master Pages

    11-10-2009, 6:11 PM

    One thing the master page does is prepends id's to your controls.  So the names are no longer the same as they were when you weren't using the masterpage. It's hard to tell for sure without seeing your code but would be my guess.

  • Re: CascadingDropDown and Master Pages

    11-12-2009, 11:55 AM
    Answer
    • Member
      6 point Member
    • jwriggs
    • Member since 04-22-2009, 4:16 PM
    • Posts 23

    Okay, some progress -

    I created a new project with a master page and a default page. The default page had three dropdownlists, with three cascadingdropdowns attached to them. The master page had one label with the text "This is my master page". When I ran this, everything worked perfectly. So the problem isn't the master page itself.

    In my original project, when I set a breakpoint on the final dropdownlist's selectedindexchanged event, it appears that the event never fires. I know that my .aspx page inherits the proper class, because I'm running some code in the Page_Load event that works correctly (I left this off of the sample code for brevity's sake).  

    Here's the code:

    <asp:Content ID="Content1" ContentPlaceHolderID="PageContent" Runat="Server">

     <div id="colTwo"><br />

        <asp:UpdatePanel runat="server">

            <ContentTemplate>

     <h1>Map Catalog</h1>     

       <div>

           <h3>How to Use the ThumbViewer</h3>

           <p>To view a larger copy of any image, simply click on the thumbnail. To close the enlarged image, click anywhere inside the picture.</p>

        </div>

     <asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList><br />

     <asp:DropDownList ID="DropDownList2" runat="server"></asp:DropDownList><br />

     <asp:DropDownList ID="DropDownList3" runat="server" AutoPostBack="True">

    </asp:DropDownList><br />

    <br />

    <asp:Label ID="Label1" runat="server"></asp:Label><br />

                        <br />

     <cc1:cascadingdropdown id="CascadingDropDown1" runat="server" category="Make"

    loadingtext="[Loading makes...]" prompttext="Please select a make" servicemethod="GetDropDownContents"

    servicepath="Map_Gallery.asmx" targetcontrolid="DropDownList1">

    </cc1:cascadingdropdown>

    <cc1:cascadingdropdown id="CascadingDropDown2" runat="server" category="Model"

    loadingtext="[Loading models...]" parentcontrolid="DropDownList1" prompttext="Please select a model"

    servicemethod="GetDropDownContents" ServicePath="Map_Gallery.asmx" targetcontrolid="DropDownList2">

    </cc1:cascadingdropdown>

    <cc1:cascadingdropdown id="CascadingDropDown3" runat="server" category="Color"

    loadingtext="[Loading colors...]" parentcontrolid="DropDownList2" prompttext="Please select a color"

    servicemethod="GetDropDownContents" servicepath="Map_Gallery.asmx" targetcontrolid="DropDownList3">

    </cc1:cascadingdropdown>

                        &nbsp;

    </ContentTemplate> 

    </asp:UpdatePanel>               

    </div>

     </asp:Content>

    Partial Class _MapGallery
        Inherits System.Web.UI.Page
    
        'IMPORTANT!!! IN ORDER FOR THIS PAGE TO FUNCTION CORRECTLY, THE FILE NAME OF THE PICTURES MUST
        '*EXACTLY* MATCH THE FILE NAME OF THE .PDF's.
    
        Protected Sub DropDownList3_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList3.SelectedIndexChanged
            Dim make As String = DropDownList1.SelectedItem.Text
            Dim model As String = DropDownList2.SelectedItem.Text
            Dim color As String = DropDownList3.SelectedItem.Text
    
            If (String.IsNullOrEmpty(make)) Then
                Label1.Text = "Please select a make."
            ElseIf (String.IsNullOrEmpty(model)) Then
                Label1.Text = "Please select a model."
            ElseIf (String.IsNullOrEmpty(color)) Then
                Label1.Text = "Please select a color."
            Else
                Label1.Text = String.Format("You have chosen a {0} {1} {2}. Nice car!", color, make, model)
            End If
        End Sub
    End Class
    
    


     

Page 1 of 1 (3 items)