本文介绍了ASP.NET - 动态ModalPopupExtender的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有了动态创建LinkBut​​ton的元素的ASP.NET页面。请注意,这些元素的LinkBut​​ton不会添加到一个DataGrid,GridView控件,或中继器。

I have an ASP.NET page that has dynamically created LinkButton elements. Please note that these LinkButton elements are not added to a DataGrid, GridView, or Repeater.

在这些LinkBut​​ton的元素之一,用户点击,我想显示一个对话框。要做到这一点,我试图用一个ModalPopupExtender,并设置它的TargetControlID当用户点击LinkBut​​ton的要素之一。不幸的是这是行不通的。

When a user clicks on one of these LinkButton elements, I want to display a dialog box. To accomplish this, I was attempting to use a ModalPopupExtender and set its TargetControlID when a user clicked one of the LinkButton elements. Unfortunately this is not working.

有谁知道我可以使用相同的ModalPopupExtender多个LinkBut​​ton的要素是什么?

Does anyone know how I can use the same ModalPopupExtender with multiple LinkButton elements?

感谢您!

推荐答案

我会做正是如此:

<a href="#" onclick="doPopUp()" Text="SomeLinkButton Lookalike" />
<asp:LinkButton runat="server" ID="someHiddenButton" CssClass="hidden" />

然后JavaScript的:

then javascript:

function doPopUp(){
    var somehiddenbutton = 
        document.getElementById('<%= someHiddenButton.ClientID %>');
        somehiddenbutton.click();
}

然后,你可以简单地与CSS属性显示中用runat服务器的LinkBut​​ton:没有,这将是你的TargetControlID您ModalPopupExtender

Then you can simply have a runat server linkbutton with CSS property display:none, and that will be your TargetControlID for your ModalPopupExtender.

希望这有助于
JP

Hope this helps,JP

编辑:我并没有包括。点击()方法。 傻瓜时刻

I didn't include the .click() method. dunce moment

这篇关于ASP.NET - 动态ModalPopupExtender的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 11:42