如何设置TargetContrlID在ModalPopupExtender在一个GridView控件 [英] How to set TargetContrlID in ModalPopupExtender with a control in a GridView

查看:147
本文介绍了如何设置TargetContrlID在ModalPopupExtender在一个GridView控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置 TragetContriID 超链接这是一个里面的GridView

我试过这样:

<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
                        PopupControlID="Panel1" 
                        CancelControlID="btnCancel" 
                        OnCancelScript="HideModalPopup()"
                        TargetControlID="GridView1$HyperLink1">
</asp:ModalPopupExtender>

不过,我有一个错误:没有 GridView1 $ HyperLink1

推荐答案

设置的TargetControlID ModalPopupExtender 基本触发ModalPopup的客户端播放功能,单击控件时。所以,你需要接线了控制自己。

Setting the TargetControlID of the ModalPopupExtender basically trigger the client side Show function of that ModalPopup when the control is clicked. So you need to wire up the controls yourself.

首先,由于 ModalPopupExtender 需要的TargetControlID ,您应该添加一个虚拟控制的模式弹出链接

First, since the ModalPopupExtender need a TargetControlID, you should add a dummy control to link the modal popup to :

<asp:Button runat="server" 
            ID="HiddenTargetControlForModalPopup" 
            style="display:none"/> 

和链接 ModalPopupExtender 的TargetControlID

<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
                        PopupControlID="Panel1" 
                        CancelControlID="btnCancel" 
                        OnCancelScript="HideModalPopup()"  
                        TargetControlID="HiddenTargetControlForModalPopup">
</asp:ModalPopupExtender>

所以 ModalPopupExtender 现在有一个目标是什么也不做。现在,我们现在需要做的目标的工作。你需要一个JavaScript函数来显示来自客户端的ModalPopup。

So 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.

<script type="text/javascript">
     var ModalPopup='<%= ModalPopupExtender1.ClientID %>';

     function ShowModalPopup() {
         //  show the Popup     
         $find(ModalPopup).show();
     }
</script>   

那么你应该在你的 GridView控件控件的的OnClientClick 事件映射到这个JavaScript函数。从code,我看你使用 ASP:超链接,我不认为它支持的OnClientClick 事件,所以你可能需要将其切换到 ASP:LinkBut​​ton的

Then you should map the OnClientClick event of the control in your gridview to this javascript function. From your code, I see that you use a asp:HyperLink, I don't think it support the OnClientClick event, so you probably need to switch it to a asp:LinkButton.

<asp:LinkButton ID="LinkButton1" runat="server" 
                OnClientClick="ShowModalPopup()" />

这篇关于如何设置TargetContrlID在ModalPopupExtender在一个GridView控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆