i thought this was a simple issue until i started searching for answers and realised it's so simple i'm the only one who has it
my user control isnt displaying anything. what am i doing wrong? (besides letting this be my life...)
control:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ctrl.ascx.cs" Inherits="proj.UserControls.ctrl" %>
asdjkldasfjasdfljdfasjklasdfjkl
use:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="page.aspx.cs" Inherits="proj.Admin.page" %>
<%@ Register assembly="proj" namespace="proj.UserControls" tagprefix="cc1" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<cc1:ctrl ID="test" runat="server" />
</asp:Content>
Change:-
<%@ Register assembly="proj" namespace="proj.UserControls" tagprefix="cc1" %>
To
<%@ Register TagPrefix="cc1" TagName="ctrl" Src="/path/to/ctrl.ascx" %>
You're missing TagName
, which represents the text following the colon in the control declaration. You're also not telling the engine where to find the source file ( Src
attribute ). Change /path/to
to represent the path from root to your control.
IF you have created custom control then you should add reference of the dll of your custom control ( from choose items from ToolBox of Visual Studio). and then Use the following tag in the page :
<%@ Register assembly="proj" namespace="proj.UserControls" tagprefix="cc1" %>
If you created User Control then add the following line in your page:
<%@ Register src="~/UserControls/ctrl.ascx" TagName="ctrl" tagprefix="cc1" %>
instead of
<%@ Register assembly="proj" namespace="proj.UserControls" tagprefix="cc1" %>
use
<%@ Register src="~/UserControls/ctrl.ascx" TagName="ctrl" tagprefix="cc1" %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With