posted 1/9/2009 by Sumit Arora
I was using modal pop up for both add and edit option on the same page. For this i used ModalPopupExtender of ajaxToolKit .But the
problem which i faced was that when ever i clicked on the edit button.The pop up just came out but i didnt make any changes in the
fields .So i clicked on the cancel button and the modal pop up just diappeared.The next time when i clicked on the add link the modal
pop up appeared but it contained the values of the edit link which i clicked before clicking on the add link.
This is the code which i was using in the aspx side
<ajaxToolkit:ModalPopupExtender ID="mpeCategoryName" runat="server" TargetControlID="lnkBtnAddCategoryName" PopupControlID="pnlCategory" DropShadow="true" BackgroundCssClass="modalBackground" EnableViewState="false" CancelControlID="btnCancelPopup1"> </ajaxToolkit:ModalPopupExtender> <asp:Panel ID="pnlCategory" runat="server" Width="300px" Height="150px" Style="display: none"> <table bgcolor="White" border="0"> <tr> <td> <asp:Button ID="btnCancelPopup1" runat="server" Text="Cancel" OnClick="btnCancelPopup1_Click" /> </td> </tr> </table> </asp:Panel>
One of my senior colleague told me to remove CancelControlID="btnCancelPopup1" from here
<ajaxToolkit:ModalPopupExtender ID="mpeCategoryName" runat="server" TargetControlID="lnkBtnAddCategoryName" PopupControlID="pnlCategory" DropShadow="true" BackgroundCssClass="modalBackground" EnableViewState="false" CancelControlID="btnCancelPopup1">
and use this in the .cs side mpeCategoryName.Hide(); on click event of cancel button and it worked.
protected void btnCancelPopup1_Click(object sender, EventArgs e) { mpeCategoryName.Hide(); }
Hope it will help you.
What kind of email newsletter would you prefer to receive from CodeAsp.Net?18