Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute server side code on ModalPopupExtender okcontrolid clicked

I am using ASP.NET and C#. I want to popup this little screen, then when the OK button is clicked, I want to update the main screen based on the input to the popup. Sounds like it should be a regular thing. Is it possible, and if so, how?

    <cc1:modalpopupextender id="ModalPopupExtender1" runat="server" 
cancelcontrolid="btnCancel" okcontrolid="btnOkay" 
targetcontrolid="txtCosCodeExpCode" popupcontrolid="Panel1" 
popupdraghandlecontrolid="PopupHeader" drag="true" 
backgroundcssclass="ModalPopupBG">
    </cc1:modalpopupextender>

    <asp:panel id="Panel1" style="display: none" runat="server">
<div class="CostCentreExpenseCodePopup" style="background-color:White ; border-style :solid;">
            <div class="PopupHeader" id="PopupHeader">Select Cost Centre / Expense Code</div>
            <div class="PopupBody">
                <p>Cost Centre<asp:DropDownList 
                                            ID="ddlCostCentres1" 
                                            runat="server" 
                                            CssClass="SVSComboBox1" 
                                            AppendDataBoundItems ="True"
                                            AutoPostBack="True" 
                                            style = "width :152px;"
                                            OnSelectedIndexChanged="ddlCostCentres1_SelectedIndexChanged">
                                            <asp:ListItem Text="Please select" Value="0"></asp:ListItem>
                                        </asp:DropDownList></p>

                <p>Expense Code <asp:DropDownList ID="ddlExpCode1" runat="server" CssClass="SVSComboBox1" style = "width :152px;"
                                            AppendDataBoundItems ="True" Enabled="False" Visible ="False">
                                            <asp:ListItem Text="Please select" Value="0"></asp:ListItem>
                                        </asp:DropDownList></p>
            </div>
            <div class="Controls">
                <input id="btnOkay" type="button" value="Done" />
                <input id="btnCancel" type="button" value="Cancel" />
    </div>
    </div>

like image 1000
Steve Staple Avatar asked Dec 15 '25 13:12

Steve Staple


1 Answers

Don't set OkControlID but use ModalPopupExtender1.Hide() on server-side. Then you're able to call your update-code first.

You should also use server-buttons instead of <input id="btnOkay" type="button" value="Done" /> and handle their click-event.

like image 129
Tim Schmelter Avatar answered Dec 17 '25 03:12

Tim Schmelter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!