我无法从后面的代码访问我的 Div

I cannot access my Div from the Code behind

我无法从 ASP.NET 中的代码访问 div 元素:

在我的 aspx 文件中:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ContactForm.aspx.cs" Inherits="Form_Mailer_ContactForm" %>
...
<div  runat="server" id="SentFormDiv">
    <s>my content</s>
</div>

对应的.cs文件内(ContactForm.aspx):

protected void Page_Load(object sender, EventArgs e) 
{
    this.SentFormDiv.Visible=false; 
}

我收到常见的编译错误消息:

does not contain a definition for 'SentFormDiv' and no extension method 'SentFormDiv' accepting a first argument of type 'xxx.SentFormDiv' could be found (are you missing a using directive or an assembly reference?)

奇怪的是,我开始在后面的代码中输入 SentFor,Intellisense 确实建议我 SentFormDiv!!

我错过了什么?

请参考此 SO 问题寻求帮助。没有看到你的完整代码,就没有办法给你一个明确的答案。此外,顺便说一句,this.SentFormDiv 可以简化为 SentFormDiv.