Setting TargetControlID ModalPopupExtender basically launches the client side. Shows the function of this ModalPopup when the control is clicked. Therefore, you need to connect the controls yourself.
First, since ModalPopupExtender needs a TargetControlID , you must add a dummy control to associate the modal popup with:
<asp:Button runat="server" ID="HiddenTargetControlForModalPopup" style="display:none"/>
And the ModalPopupExtender TargetControlID link to it
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="Panel1" CancelControlID="btnCancel" OnCancelScript="HideModalPopup()" TargetControlID="HiddenTargetControlForModalPopup"> </asp:ModalPopupExtender>
So, ModalPopupExtender now has a target that does nothing. Now we need to do the targeted work. You need a javascript function to show ModalPopup on the client side.
<script type="text/javascript"> var ModalPopup='<%= ModalPopupExtender1.ClientID %>'; function ShowModalPopup() { </script>
Then you must map the OnClientClick event of the control in the gridview to this javascript function. From your code, I see that you are using asp:HyperLink , I donβt think it supports the OnClientClick event, so you probably need to switch it to asp:LinkButton .
<asp:LinkButton ID="LinkButton1" runat="server" OnClientClick="ShowModalPopup()" />
DavRob60
source share