I have a simple .ascx file
<%@ Control Language="C#"
AutoEventWireup="true"
CodeFile="Profile.ascx.cs"
Inherits="UserControls_Profile" %>
<%@ Register Assembly="RadChart.Net2"
Namespace="Telerik.WebControls"
TagPrefix="radC" %>
<div id="testdiv" runat="server"></div>
in code behind:
protected void Page_Load(object sender, EventArgs e) {
Chart();
}
private void Chart() {
testdiv.Visible=false;
}
When I try to access the page I get the exception:
error CS0103: The name ‘testdiv’ does not exist in the current context
I have tried onload as well but same result!
If you have an HTML div, you need to add a runat attribute like
HTML elements like div’s are not ASP.NET Controls though and mixing HTML “controls” with ASP.NET might be problematic. You may prefer to do something like
Update: Also check Profile.ascx.designer.cs which should be auto-generated by Visual Studio to contain “protected HtmlControl testdiv”. I assume that is missing from the partial class. I note you derive from UserControls_Profile which may be cause for confusion.