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)
{
int reservId = Convert.ToInt32(hfReservationDetailId.Value);
Product product2;
Site site2;
ReservationDetails reservationDetails2 = new ReservationDetails();
reservationDetails2.Load(Session["connection"].ToString(), reservId);
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()));
}
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()));
}
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.