如何访问asp.net页中的Web用户控件元素. [英] How to access web user control elements in asp.net page.
本文介绍了如何访问asp.net页中的Web用户控件元素.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经创建了Web用户控件并将其分配给页面.我想访问Web用户控件元素,例如aspx页面上的文本框,复选框和其他服务器控件.我该如何访问?
谢谢,
Mangesh:-)
I have created web user control and assign it to a page. I want to access web user control elements such as textbox, checkbox and other server control on a aspx page. How could i approach to access ?
Thanks,
Mangesh :-)
推荐答案
最简单,最可靠的方法是使用get-set将用户控件中的控件公开为公共属性.这样,直接使用usercontrol对象,就可以访问并使用这些控件.
Easiest and robust way would be to expose the controls in user control as public properties using get-set. This way, directly using usercontrol object, you can access those controls and use them.
您必须通过以下方法添加该控件
you have to add that control by below method
<%@ Register Src="WebUserControl.ascx" TagName="WebUserControl" TagPrefix="uc1" %>
这篇关于如何访问asp.net页中的Web用户控件元素.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文