Click here to Skip to main content
15,886,860 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
C#
<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

C#
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
Posted
Updated 24-Jul-12 2:52am
v2
Comments
Shemeer NS 24-Jul-12 6:04am    
You are saving the data to the database from the server code then why looking for client script to clear the data from controls? Whats the exact problem you are facing...

1 solution

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
SQL
OnOkScript - Script to run when the modal popup is dismissed with the OkControlID
but make suere that you have captured the value to save.
 
Share this answer
 
Comments
palcordis 24-Jul-12 8:54am    
Hello NS,
I updated my question could you please explain me further a bit.
Shemeer NS 24-Jul-12 8:58am    
from this "defSave_Command" event your data is getting saved properly?
palcordis 24-Jul-12 9:33am    
sorry that is "btnSave_Command" event.
yes saving properly.
Shemeer NS 24-Jul-12 11:34am    
I don't think your data is saving to the database from the button click! are you sure?
Shemeer NS 24-Jul-12 11:37am    
try setting the causesvalidation=false and validate in server side or try setting ValidationGroup or else try adding dummy controls for ok button for the popop okcontrolid

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900