Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

user control not rendering content of ascx

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>
like image 909
user1566694 Avatar asked Nov 27 '12 16:11

user1566694


3 Answers

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.

like image 141
Paul Alan Taylor Avatar answered Oct 31 '22 14:10

Paul Alan Taylor


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" %>

like image 23
Samir Varteji Avatar answered Oct 31 '22 13:10

Samir Varteji


instead of

<%@ Register assembly="proj" namespace="proj.UserControls" tagprefix="cc1" %>

use

 <%@ Register  src="~/UserControls/ctrl.ascx"  TagName="ctrl" tagprefix="cc1" %>
like image 36
Mahmoud Farahat Avatar answered Oct 31 '22 14:10

Mahmoud Farahat