本文介绍了在运行时设置ModalPopupextender的TargetControl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在aspx页面后面的代码中创建了一个按钮控件.我想将此按钮控件设置为ModalPopupExtender的TargetControlID.
这是我正在编码的内容:
I have created a button control in code behind of an aspx page. I want to set this button control as TargetControlID of a ModalPopupExtender.
Here is what I am coding:
Button btnPostComment = new Button();
btnPostComment.Text = "Post Your Comment Here";
btnPostComment.ID = "btnPostComment";
ModalPopupExtender1.TargetControlID = Convert.ToString(Page.FindControl(Convert.ToString(btnPostComment.ClientID)));
它给出了一个例外:
"ModalPopupExtender1"的TargetControlID无效.该值不能为null或为空.
It gives an exception:
The TargetControlID of ''ModalPopupExtender1'' is not valid. The value cannot be null or empty.
How can I set the targetControlID at codebehind?
推荐答案
ModalPopupExtender1.TargetControlID = "btnPostComment";
这篇关于在运行时设置ModalPopupextender的TargetControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!