带有下拉列表的modalpopupExtender [英] modalpopupExtender with dropdownlist

查看:46
本文介绍了带有下拉列表的modalpopupExtender的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!
我用面板制作了一个页面,该面板将使用modalpopupextender显示为弹出窗口,该面板必须具有一个dropdownlist cold类别,当在类别中进行选择时,该类别必须加载另一个dropdownlist cold子类别,以便加载子类别弹出窗口会由于自动回发而自行关闭
如何加载仍打开的子类别和弹出窗口


弹出面板:

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:



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.

推荐答案

将下拉列表放在update panel中,这将停止发回完整文章.
Place the dropdown list in an update panel which will stop full post back.


这篇关于带有下拉列表的modalpopupExtender的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆