使用c#的模态弹出扩展按钮事件

时间:2016-05-19 08:10:10

标签: c# jquery asp.net

我写过modalpopupextender并且它已成功显示。我的问题是在modalpopup中输入文本后我会点击保存按钮但它不起作用,点击按钮弹出窗口将关闭,数据将不会存储在我的数据库中以下是aspx代码

 <asp:Button ID="freeservice" runat="server" CssClass="hidden" />
    <asp:ModalPopupExtender ID="ModalPopupExtender" runat="server" BehaviorID="mpe" PopupControlID="panel" TargetControlID="freeservice" OkControlID="savetxt"  BackgroundCssClass="modalBackground" CancelControlID="cancel"></asp:ModalPopupExtender>
    <asp:Panel ID="panel" runat="server" CssClass="modalPopup" Style="display: none;">
        <asp:Button ID="cancel" runat="server" Text="X" CssClass="modalDialog" />
        <div class="Popup_header">
            Free service
        </div>
        <div class="modalbody">
            <h3>Do you want to get free text update on your mobile when IRS takes decision on your
            form?
            <br />
                If yes, please enter mobile number on which you want to get update:</h3>
            <table>
                <tr>
                    <td>Mobile Number</td>
                    <td style="width: 1px">
                       <asp:TextBox ID="txtmobile" runat="server" CssClass="divtxt"></asp:TextBox>
                        <asp:RegularExpressionValidator ID="revmobile" runat="server" SetFocusOnError="true"
                             Display="None" ErrorMessage="Mobile number must be of 10 digits" ControlToValidate="txtmobile"
                             ValidationExpression="[0-9]{10}"></asp:RegularExpressionValidator>
                        <asp:ValidatorCalloutExtender ID="vce_revmobile" runat="server" PopupPosition="Right" 
                            TargetControlID="revmobile" HighlightCssClass="errorField"></asp:ValidatorCalloutExtender>
                        <asp:FilteredTextBoxExtender ID="ftemobile" runat="server" TargetControlID="txtmobile" ValidChars="0123456789"></asp:FilteredTextBoxExtender>
                    </td>
                    <td>(Not Mandatory)</td>
                </tr>
            </table>
            <h3>Do you want to get Schedule 1 by fax for free?
            <br />
                If yes, please enter fax number where you want to receive your Schedule 1:
            </h3>
            <table>
                <tr>
                    <td style="width:24%">Fax Number</td>
                    <td style="width: 1px">
                       <asp:TextBox ID="txtfax" runat="server" CssClass="divtxt"></asp:TextBox>
                        <asp:RegularExpressionValidator ID="revfax" runat="server" ControlToValidate="txtfax" SetFocusOnError="true" Display="None" ErrorMessage="Fax number must be of 10 digits"></asp:RegularExpressionValidator>
                        <asp:ValidatorCalloutExtender ID="vce_revfax" runat="server" PopupPosition="Right" TargetControlID="revfax" HighlightCssClass="errorField"></asp:ValidatorCalloutExtender>
                        <asp:FilteredTextBoxExtender ID="ftefax" runat="server" TargetControlID="txtfax" ValidChars="0123456789"></asp:FilteredTextBoxExtender>
                    </td>
                    <td>(Not Mandatory)</td>
                </tr>
            </table>
        </div>
        <div style="text-align: right; padding-top: 6px;">
           <asp:Button runat="server" ID="savetxt" OnClick="savetxt_Click" Text="Save" CssClass="btn" />
        </div>
    </asp:Panel>

我的后端代码是

 protected void savetxt_Click(object sender, EventArgs e)
    {
        try
        {

            Form2290.FreeServices objFreeService = new FreeServices();

            objFreeService.FormID = Convert.ToString(Session["FORM_KEY"]);
            objFreeService.Mobile = txtmobile.Text.Trim();
            objFreeService.Fax = txtfax.Text.Trim();

            BAL_F2290 objBAL = new BAL_F2290();
            objBAL.SaveFreeServices(objFreeService);
        }
        catch (Exception ex)
        {
            string a = ex.Message;
        }
    }

请帮帮我

1 个答案:

答案 0 :(得分:0)

抱歉,我在modalpopupextender中犯了错误,我设置了 okcontrolID =&#34; savetxt&#34; 不应该在那里。我删除了代码并成功执行了代码。谢谢大家帮助我