在代码隐藏中无法识别控件 [英] Don’t recognize control in codebehind
本文介绍了在代码隐藏中无法识别控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我在主页上放了一个标签.我想在代码隐藏中访问它,但奇怪的是我无法访问它.为什么?
非常感谢
Hi
I put a lable in my masterpage. I wants to access it in codebehind but strangely I can''t to access it . Why?
Thanks very much
推荐答案
如果还没有准备好,请将此行添加到页面(不是母版!)中.
If you don''t have it allready, add this line to your page (not the masterpage!)
<![CDATA[<%@ MasterType virtualpath="~/Masters/Master1.master" %>]]>
其中〜/Masters/Master1.master"是母版页的路径
然后,您可以访问母版上的控件:
Where "~/Masters/Master1.master" is the path to the master page
You can then access controls on the master:
Control c = Master.FindControl("ControlName");
这篇关于在代码隐藏中无法识别控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文