清除Ajax Modal弹出窗口Extender Popup窗口 [英] Ajax Modal popup Extender Popup window clear

查看:55
本文介绍了清除Ajax Modal弹出窗口Extender Popup窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在使用Ajax模态弹出式扩展程序来捕获一些细节.
在弹出的窗口中,我有一个带有一些文本框的SAVE按钮,用于将记录保存到数据库中.
我希望一旦将它们保存在数据库中后,单击保存"按钮后应清除弹出"窗口中的所有控件.
这是我的aspx页面,下面是

< asp:Button ID = "  runat = "  Text = " 添加"/>
< asp:Panel ID = "  runat =  "  BackColor = " 高度= "  Width = "  400px" style =  显示:无" "  style = " 边框:实心3px#D55500;宽度:100%;高度:100%" cellpadding =   0" cellspacing =   0" > 
                        < tr>
                        < td colspan = "  style = " 高度:10%;颜色:绿色;字体重量:粗体;字体大小:较大"  align =  " >输入员工详细信息</ > 
                        </  tr  > 
                        < tr>
                        < td align = " >名称: </  td  > 
                        < td>< asp:TextBox ID = "  runat =  服务器"/>
                        < asp:RequiredFieldValidator ID = "  runat =  " 
                            ControlToValidate = "  ErrorMessage = "  *请输入名称">! asp :RequiredFieldValidator  > 
                        </  td  > 
                        </  tr  > 
                        < tr>
                        < td align = " >地址: </  td  > 
                        < td>< asp:TextBox ID = "  runat =  服务器"/>  td  </  tr  > 
                        < tr>
                        < td align = " >工资: </  td  > 
                        < td>< asp:TextBox ID = "  runat =  服务器"/>  td  </  tr  > 
                        < tr>
                        < td align = " >电话: </  td  > 
                        < td>< asp:TextBox ID = "  runat =  服务器"/>  td  </  tr  > 
                        < tr>
                        < td> </  td  > 
                        < td>< asp:按钮ID = "  CommandName =  保存" runat =   Text = " 
                                oncommand = " />
                            < asp:按钮ID = "  runat =  "  Text = " />
                        </  td  > 
                        </  tr  > 
                        </  > 
                    </  asp:Panel  > 

                       < cc1:modalpopupextender ID = "  runat =  " 
                            TargetControlID = " 
                            PopupControlID = " 
                            BackgroundCssClass = " 
                            CancelControlID = "  > 
                       </  cc1:modalpopupextender  >  



在后面的代码中,我写了一些代码以在单击SAVE按钮后保存记录

 受保护的  void  defSave_Command(对象发​​件人,CommandEventArgs e)
        {
            // 写了一些逻辑来保存... 
             .ModalPopupExtender1.Hide();
        } 



在这里,我的问题是,执行保存"按钮后,模态弹出窗口没有隐藏,单击保存"按钮后,弹出控件将被清除.

请帮帮我...

谢谢,
palcordis

解决方案

您只需从save事件本身中清除控件值即可.
最好的方法是在显示模式弹出窗口时清除控件,您可以为此目的使用onShowing事件
如果只想通过客户端脚本执行操作,则在模态弹出扩展OnOkScript中寻求帮助.

 OnOkScript-脚本 to 运行    :            取消模式弹出窗口  pre>,但要确保已捕获要保存的值.


Hi All,

I am using Ajax modal popup extender to capture some details.
In the pop up window I have SAVE button with some textboxes to save the records in to the database.
I want all the controls in Popup window should be cleared after clicking the SAVE button once they are saved in the Database.
This is my aspx page below

<asp:Button ID="Button1" runat="server" Text="Add" />
<asp:Panel ID="pnlpopup" runat="server" BackColor="White" Height="269px" Width="400px" style="display:none">
                        <table width="100%" style="border:Solid 3px #D55500; width:100%; height:100%" cellpadding="0" cellspacing="0">
                        <tr>
                        <td colspan="2" style=" height:10%; color:Green; font-weight:bold; font-size:larger" align="center">Enter Employee details</td>
                        </tr>              
                        <tr>
                        <td align="right">Name : </td>
                        <td><asp:TextBox ID="txt1" runat="server"/>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                            ControlToValidate="txtName" ErrorMessage="* Please Enter Name">!</asp:RequiredFieldValidator>
                        </td>
                        </tr>
                        <tr>
                        <td align="right">Address : </td>
                        <td><asp:TextBox ID="txt2" runat="server"/></td>
                        </tr>
                        <tr>
                        <td align="right">Salary : </td>
                        <td><asp:TextBox ID="txt3" runat="server"/></td>
                        </tr>
                        <tr>
                        <td align="right">Phone: </td>
                        <td><asp:TextBox ID="txt4" runat="server"/></td>
                        </tr>                           
                        <tr>
                        <td></td>
                        <td><asp:Button ID="btnSave" CommandName="Save" runat="server" Text="Save" 
                                oncommand="btnSave_Command"/>
                            <asp:Button ID="btnCancel" runat="server" Text="Cancel" />
                        </td>
                        </tr>
                        </table>
                    </asp:Panel>

                       <cc1:modalpopupextender ID="ModalPopupExtender1"  runat="server" 
                            TargetControlID="Button1"
                            PopupControlID="pnlpopup" 
                            BackgroundCssClass="modalBackground"                           
                            CancelControlID="btnCancel">
                       </cc1:modalpopupextender>



And in the code behind I written some code to save the records after SAVE button clicked

protected void defSave_Command(object sender, CommandEventArgs e)
        {
            //written some logic to save...
            this.ModalPopupExtender1.Hide();
        }



Here my problem is Modal-popup is not hiding after executing SAVE button and after clicking save button the popup controls to be cleared.

Please help me...

Thanks,
palcordis

解决方案

You can simply clear the controls value from the save event itself....

The best way is to clear the controls when showing the modal popup, you can use the onShowing event for this purpose
If you want to do by client script only then go for..OnOkScript in Modal popupextendar

OnOkScript - Script to run when the modal popup is dismissed with the OkControlID

but make suere that you have captured the value to save.


这篇关于清除Ajax Modal弹出窗口Extender Popup窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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