ModalPopup TargetControlID is a Control Inside a DetailsView
Posted on 2007-04-10
I have a details view which I am using in Insert Mode to insert a record into a DB. One of the fields in my DetailsView is a DropDownList, next to the DDL is a LinkButton. I would like a Modal PopUp to appear when that LinkButton is clicked, which allows the user to quickly add something to the DropDownList.
I have it all working when my LinkButton which I am using as the TargetControlID is outside of my DetailsView, but when it is in the DetailsView, and I change the TargetControlID to use it's full name, the Modal PopUp appears, but then closes. It's only on the screen for a few milliseconds.
I have two LinkButtons, one inside the DetailsView, another outside the DetailsView, the outside one is hidden, I then use the OnClientClick method to force the hidden LinkButton to be clicked when the link button inside the DetailsView is clicked.
Here is some of my code:
<asp:LinkButton ID="cmdAddNewEvidenceType" runat="server" OnClientClick="ctl00_cphBodyText_cmdHiddenAddNewEvidenceType.click();" Text="Add New" />
asp:LinkButton ID="cmdHiddenAddNewEvidenceType" runat="server" Style="visibility: hidden" />
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server" TargetControlID="cmdHiddenAddNewEvidenceType"
PopupControlID="palAddEvidenceItemType" BackgroundCssClass="modalBackground" CancelControlID="cmdCancelAdd"