Posted on: 1/28/2014 8:43:15 PM | Views : 580

Is it possible to use a codebehind with an ascx file? Below is my code but, I'm curently receiving the error: The directive 'control' is unknown., in my ascx file.

My ascx file:
<%@ Control Language="C#" ClassName="sidebar_emaillist" Codebehind="~/sidebar-resources.ascx.cs" Inherits="sidebar_emaillist" %> <div class="form_sidebar"> // a bunch of stuff </div> My ascx.cs file:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.IO; using System.Text; public partial class sidebar_emaillist : System.Web.UI.Control { protected void Page_Load(object sender, EventArgs e) { } protected void cmd_Email(object sender, EventArgs e) { string path = Server.MapPath("~/App_Data/data.txt"); ...

Go to the complete details ...