如何使用 GridView 中的控件在 ModalPopupExtender 中设置 TargetContrlID
如何将 TragetContriID
设置为 GridView
内的 HyperLink
?
我尝试了这个:
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
PopupControlID="Panel1"
CancelControlID="btnCancel"
OnCancelScript="HideModalPopup()"
TargetControlID="GridView1$HyperLink1">
</asp:ModalPopupExtender>
但我有一个错误:没有 GridView1$HyperLink1
How can I set TragetContriID
to a HyperLink
that is inside a GridView
?
I tried this :
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
PopupControlID="Panel1"
CancelControlID="btnCancel"
OnCancelScript="HideModalPopup()"
TargetControlID="GridView1$HyperLink1">
</asp:ModalPopupExtender>
But I have an error: that there is no GridView1$HyperLink1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
设置 ModalPopupExtender 的 TargetControlID 基本上会在单击控件时触发该 ModalPopup 的客户端 Show 函数。因此,您需要自己连接控制装置。
首先,由于
ModalPopupExtender
需要TargetControlID
,因此您应该添加一个虚拟控件来将模态弹出窗口链接到:并链接
ModalPopupExtender
TargetControlID
到它所以
ModalPopupExtender
现在有一个不执行任何操作的目标。现在我们需要完成目标的工作。您需要一个 javascript 函数来从客户端显示 ModalPopup。然后,您应该将
gridview
中控件的OnClientClick
事件映射到此 JavaScript 函数。从您的代码中,我看到您使用asp:HyperLink
,我认为它不支持OnClientClick
事件,因此您可能需要将其切换为asp:LinkButton
.Setting the
TargetControlID
of theModalPopupExtender
basically trigger the client side Show function of that ModalPopup when the control is clicked. So you need to wire up the controls yourself.First, since the
ModalPopupExtender
need aTargetControlID
, you should add a dummy control to link the modal popup to :And link the
ModalPopupExtender
TargetControlID
to itSo the
ModalPopupExtender
now has a target that do nothing. Now we now need to do the target's job. You need a javascript function to show the ModalPopup from client side.Then you should map the
OnClientClick
event of the control in yourgridview
to this javascript function. From your code, I see that you use aasp:HyperLink
, I don't think it support theOnClientClick
event, so you probably need to switch it to aasp:LinkButton
.