首页 > 解决方案 > 查找控件返回 null

问题描述

当我试图在当前页面上找到一个控件时,它每次都返回 null 并且控件就在那里。

HTML:

<input type="radio" id="test2" value="Hello World" name="Test"/>

代码背后

HtmlInputRadioButton control = (HtmlInputRadioButton)Page.FindControl("test2");
            Response.Write(control.Value);
            Response.Write(control.ID);

知道为什么它一直返回 null 吗?

在此处输入图像描述

标签: c#htmlasp.netnullreferenceexceptionfindcontrol

解决方案


推荐阅读