Find a control on a page with a master page

自作多情 提交于 2019-11-27 15:30:38
Vinay B R

Try this

Table tblForm = this.Master.FindControl("MainContent").FindControl("formtable") as Table; 

Checkout this Control ID Naming in Content Pages for more details

Working with findControl() cause complications sometimes. It is easier to define a public property for that control in master page and then access control through the property.

you should add this line in child page:

<%@ MasterType VirtualPath="~/MasterPage.master" %>

What context are you in when you are trying to do this? Are you in the codebehind of the individual page?

If you are it should be Content1.FindControl("formtable") as Table and that would be it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!