问题描述
我有了动态创建LinkButton的元素的ASP.NET页面。请注意,这些元素的LinkButton不会添加到一个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.
在这些LinkButton的元素之一,用户点击,我想显示一个对话框。要做到这一点,我试图用一个ModalPopupExtender,并设置它的TargetControlID当用户点击LinkButton的要素之一。不幸的是这是行不通的。
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多个LinkButton的要素是什么?
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服务器的LinkButton:没有,这将是你的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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!