Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hi guys!
i made page with a panel which will be display as popup window using modalpopupextender, that panel has to have a dropdownlist cold category which must load another dropdownlist cold subcategory when select in category in order to load subcategory popup is closed it self because of autopostback
how can i load that subcategory and popup still be open


popup panel:
<pre lang="xml"><asp:Panel ID="pnlClientPopup" runat="server" CssClass="modalPopup" Style="display: none" Width="668px" OnLoad="pnlClientPopup_Load">

     <table width="100%" style="font-family: 'Trebuchet MS', Tahoma, Verdana;">
<tr><td bgcolor="skyblue" align="center">
          <u>Client Registration</u>
    </td>
</tr>
<tr>
<td>
    <asp:Label ID="Label4" runat="server" Text="" ForeColor="Red"></asp:Label>
    <asp:Label ID="lblErrorOnClientRegistration" runat="server" Text="" ></asp:Label>
    <asp:DropDownList ID="ddlProductByClient" runat="server">
    </asp:DropDownList>
</td>
</tr>
<tr>
    <td>
        <table>
        <tr>
            <td class="style1">Names</td>
            <td><asp:TextBox ID="txtNames" Width="185px" runat="server"></asp:TextBox></td>
            <td class="style1">Address</td>
            <td><asp:TextBox ID="txtContact" runat="server" TextMode ="MultiLine"  ></asp:TextBox></td>
        </tr>
        <tr>
            <td class="style1"> Phone Number</td>
            <td><asp:TextBox ID="txtPhoneNumber" runat ="server" Width="183px" />
                                </td>
            <td>E-mail</td>
            <td><asp:TextBox ID="txtEmail" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
                <td class="style1">ID Type</td>
                <td><asp:DropDownList ID="ddlIDType" runat="server"
                        ></asp:DropDownList>
                    <cc1:DropDownExtender ID="ddlIDTypeExt" TargetControlID="ddlIDType" runat="server">
                    </cc1:DropDownExtender>
                </td>
                <td>ID Number</td>
                <td><asp:TextBox ID="txtIDNumber" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
            <td class="style1">Category</td>
            <td><asp:DropDownList ID="ddlCategory" runat="server">
            </asp:DropDownList><cc1:DropDownExtender ID="ddlCategoryExt" TargetControlID="ddlCategory" runat="server">
                </cc1:DropDownExtender></td>
            <td> <asp:Label ID="Label7" runat="server" Text="" ForeColor="Red"></asp:Label></td>
            <td><asp:DropDownList ID="ddlSubCategory" runat="server" ></asp:DropDownList>


            </td>
        </tr><tr><td>  <asp:HiddenField ID="HFClientID" Value="0" runat="server" /></td></tr><tr><td><asp:Label ID="Label6" runat="server" Text="" ForeColor="Red"></asp:Label></td></tr>
        <tr>
        <td class="style1">Nationality</td>
            <td><asp:DropDownList ID="ddlCountry0" runat="server"></asp:DropDownList>
                <cc1:DropDownExtender ID="ddlCountry0Ext" TargetControlID="ddlCountry0"  runat="server">
                </cc1:DropDownExtender>
            </td>
        <td>
            <asp:Button ID="btnAddClient" runat="server" Text="save client" />
            </td>
        <td>
            <asp:Button ID="btnCancelPopup" runat="server" Text="Cancel"/>
            </td>

        </tr>
    </table>
</td></tr>

</table>
         </asp:Panel>
        <asp:Label ID="lblHidden" runat="server" Text="hidden" CssClass="hidelbl"></asp:Label>




method to load a popup:
protected void pnlClientPopup_Load(object sender, EventArgs e)
   {
       //===========for client popup===========================
       //Label2.Text = "9";


       int reservId = Convert.ToInt32(hfReservationDetailId.Value);
      // Label7.Text = hfReservationDetailId.Value;
       Product product2;
       Site site2;
       ReservationDetails reservationDetails2 = new ReservationDetails();
       reservationDetails2.Load(Session["connection"].ToString(), reservId);


           //lblError.Text = reservId.ToString();
           ddlProductByClient.Items.Clear();
           foreach (ReservationDetail reservationDetail2 in reservationDetails2)
           {
               product2 = products.get_getProductBy(reservationDetail2.Product.ProductId);
               site2 = sites.get_getSiteBy(product2.Site.SiteId);
               ddlProductByClient.Items.Add(new ListItem(site2.SiteName + " to visit " + product2.ProductName, reservationDetail2.ReservationDetailsId.ToString()));
           }

           //idTypes.Load(Session["connection"].ToString());

           //ddlIDType.Items.Clear();

           //ddlIDType.Items.Add(new ListItem("-Choose an ID Type-", "0"));
           //foreach (IdentificationType idType in idTypes)
           //{
           //    ddlIDType.Items.Add(new ListItem(idType.IdentificationTypeName, idType.IdentificationTypeId.ToString()));
           //}

           ClientsCategories categories = new ClientsCategories();
           categories.Load(Session["connection"].ToString());

           ddlCategory.Items.Clear();
           ddlCategory.Items.Add(new ListItem("-Choose a Category-", "0"));
           foreach (ClientsCategory category in categories)
           {
               ddlCategory.Items.Add(new ListItem(category.ClientsCategoryName, category.ClientsCategoryId.ToString()));
           }


           //load countries
           countries = new Countries();
           countries.Load(Session["connection"].ToString());
           ddlCountry0.Items.Clear();
           ddlCountry0.Items.Add(new ListItem("-Choose a Country-", "0"));
           foreach (Country country in countries)
           {
               ddlCountry0.Items.Add(new ListItem(country.CountryName, country.CountryId.ToString()));
           }



   }


modalpopupextender:

<pre lang="xml"><cc1:ModalPopupExtender ID="ModalPopupExtender3" PopupControlID="pnlClientPopup" runat="server" backgroundcssclass="modalBackground" cancelcontrolid="btnCancelPopup"
   popupdraghandlecontrolid="pnlClientPopup" DropShadow="true" Enabled="true" targetcontrolid="lblHidden" BehaviorID="ModalPopupExtender3">
   </cc1:ModalPopupExtender>




method to load subcategory:
<pre lang="cs">protected void ddlCategory_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            ddlSubCategory.Items.Clear();
            if (ddlCategory.SelectedItem.Value == "0")
            {
                ddlSubCategory.Enabled = false;
            }
            else
            {
                ClientsSubCategories clientsSubCategories = new ClientsSubCategories ();
                clientsSubCategories.Load(Session["connection"].ToString(), Convert.ToInt32(ddlCategory.SelectedItem.Value));
                ddlSubCategory.Enabled = true;
                if (clientsSubCategories.Count > 0)
                {
                    if (clientsSubCategories.Count == 1)
                    {
                        foreach (ClientsSubCategory clientSubcategory in clientsSubCategories)
                        {
                            ddlSubCategory.Items.Add(new ListItem(clientSubcategory.ClientsSubCategoryName, clientSubcategory.ClientsSubCategoryId.ToString()));
                            ddlSubCategory.SelectedValue = clientSubcategory.ClientsSubCategoryId.ToString();
                        }
                    }
                    else
                    {
                        ddlSubCategory.Items.Add(new ListItem("-Choose a SubCategory-", "0"));
                        foreach (ClientsSubCategory clientSubcategory in clientsSubCategories)
                        {
                            ddlSubCategory.Items.Add(new ListItem(clientSubcategory.ClientsSubCategoryName, clientSubcategory.ClientsSubCategoryId.ToString()));
                        }
                    }
                }
                else
                {
                    ddlSubCategory.Items.Add(new ListItem("No SubCategory Found!", "0"));
                }
            }
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }


when i call that method in order to load subcategory popup closed.
Posted

1 solution

Place the dropdown list in an update panel which will stop full post back.
 
Share this answer
 
Comments
Louis Bizy 11-Apr-11 8:46am    
thank u for ur help!

update panel asks me to put script manager on same page which is not possible because I have another script manage on master page and it must be one instantiation of script manager how can i manage that?
m@dhu 11-Apr-11 9:04am    
I don't think another script manager is required. Is the panel is placed in one of the content pages where the master file is referenced.
bizimana jean louis 13-Apr-11 5:52am    
with update panel still there. there not another to refresh(or to reload) a update panel with out using autopostback. because autopostback close a popup and if i set it false subcategory don't load.
m@dhu 13-Apr-11 6:10am    
If the dropdown with autopoatback true is inside the update panel then only partial postback occurs.
check the following link.
http://forums.asp.net/t/1422287.aspx#faq_v3_6_5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900