locked
Selecting a Dropdown List item Closes the Popup Window RRS feed

  • Question

  • User1769015664 posted

    In the code below; the "AutoPostBack" is set to true. When I select an item from the dropdown list; the popup window gets close automatically but returns the selected value. If I set "AutoPostBack" to false then it won't close popup but it will not return selected value.

    What do I need to do so the popup won't close until I click on "Cancel"  or "Search" button?

    <cc1:modalpopupextender id="ModalPopupExtender1" runat="server" 
                    OnOkScript="onModalOk();"
    	            cancelcontrolid="btnCancel" 
                    okcontrolid="BtnSubmit" 
    	            targetcontrolid="lnkBtn_AddFromdatabase" 
                    popupcontrolid="panel1"
    	            popupdraghandlecontrolid="PopupHeader" drag="true" 
    	            backgroundcssclass="ModalPopupBG">
            </cc1:modalpopupextender>
    
            <asp:panel id="Panel1" style="display: none" runat="server">
    	        <div class="HellowWorldPopup">
                    <div class="PopupHeader" id="PopupHeader">Database Search</div>
                    <div></div><br /><br />
                    <div class="popup_Body" style="border:black 2px">
                    <p>&emsp;&emsp;&emsp;Name:
                        <asp:textbox id="txtName" runat="server"></asp:textbox>
                    </p>
                    <p>&emsp;&emsp;&emsp;
                        <asp:Label ID="lblCompany" runat="server" Text="Company:"></asp:Label>
                        <asp:DropDownList ID="ddl_Company" runat="server" AutoPostBack="true" OnSelectedIndexChanged="OnSelectedIndexChanged_ddlCompany"></asp:DropDownList>
                    </p>
                    <p>&emsp;&emsp;&emsp;
                        <asp:Label ID="lblID" runat="server" Text="ID:"></asp:Label>
                        <asp:DropDownList ID="ddl_Empployee" runat="server" AutoPostBack="true" OnSelectedIndexChanged="OnSelectedIndexChanged_ddlEmployee"></asp:DropDownList>
                    </p>
                </div>
                    <br /><br />
                    <div class="Controls" style="text-align:center">
                        <input id="BtnSubmit" type="button" value="Search"/>
                        <input id="btnCancel" type="button" value="Cancel" />
    		        </div>
                 </div>
            </asp:panel>
    
        <style type="text/css">
        .ModalPopupBG
    {
        background-color: #666699;
        filter: alpha(opacity=50);
        opacity: 0.7;
    }
    
    .AppPopup
    {
        min-width:400px;
        min-height:275px;
        background-color:lightsteelblue;
        border-width: 3px;
        border-style: solid;
        border-color: white;
    }
    .popupBody
    {
        min-width:400px;
        min-height:275px;
        background-color:lightsteelblue;
        border-width: 3px;
        border-style: solid;
        border-color: white;
    }
    .PopupHeader
    {
        background:green;
        background-color:navy;
        color:yellow;
    }
    </style>
    
            protected void OnSelectedIndexChanged_ddlCompany(object sender, EventArgs e)
            {
                string sSelectedValue = "Selected Item: " + ddl_Company.SelectedItem.Text;
                ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "alert", "alert('" + sSelectedValue + "');", true);
            }
    



    Wednesday, May 3, 2017 5:18 AM

Answers

  • User1769015664 posted

    Never mind; I've set the AutoPostback to false to get it to work for me.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 3, 2017 1:53 PM