A.D. A.D. - 10 months ago 46
ASP.NET (C#) Question

I cannot access my Div from the Code behind

I do not manage to access a div element from code behind in ASP.NET:

Inside my aspx file:

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

Inside the corresponding .cs file (ContactForm.aspx):

protected void Page_Load(object sender, EventArgs e)

I get the usual compilation error message:

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?)

The odd part is that is I start typing
into the code behind, the Intellisense does suggest me

What did I miss?

Answer Source

Please reference this SO question for help. Without seeing your full code, there is no way to give you a definitive answer. Also, as an aside, this.SentFormDiv can be simplified to SentFormDiv.