c# - Cannot reference my web usercontrol (ascx) from code behind -
i trying dynamically create user controls in visual studio 2012/asp.net/c# project not recognise type name of user control when try use in code behind of other aspx or ascx page. i've tried rebuilding , removing namespaces , seems should work doesn't!
the top line of ascx file this:
<%@ control language="c#" autoeventwireup="true" codefile="webusercontrol.ascx.cs" inherits="ag_controls_webusercontrol" %>
the corresponding codebehind looks this:
public partial class ag_controls_webusercontrol : system.web.ui.usercontrol { protected void page_load(object sender, eventargs e) { } }
i try declare in instance of in code behind of blank aspx page this:
ag_controls_webusercontrol test = new ag_controls_webusercontrol();
and :
error 3 type or namespace name 'ag_controls_webusercontrol' not found (are missing using directive or assembly reference?)
it's been long day , pretty tired shouldn't rocket science, can't see problem is. appreciated!
you forgot include reference control in aspx page. still need include reference if dynamically creating control in code behind.
<%@ register src="webusercontrol.ascx" tagname="webusercontrol" tagprefix="uc1" %>
Comments
Post a Comment