timu
timu

Reputation: 838

Extending Control and using problem

I need to extend Repeater control for when there is no data to display then it will not shown. So i added Class Library project to my solution and added this class to that Class Library project.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using System.Web.UI;

namespace FRMControls
{
    public class CustomRepeater:Repeater
    {
        public ITemplate EmptyDataTemplate { get; set; }

        protected override void OnDataBinding(EventArgs e)
        {
            base.OnDataBinding(e);

            if (this.Items.Count == 0)
            {
                EmptyDataTemplate.InstantiateIn(this);
            }
        }
    }
}

After writing this, i added Reference to use this Library. I adding controls to aspx page like that

<%@ Register TagPrefix="asp" Namespace="FRMControls" Assembly="FRMControls" %>

But I cant see and use that control What i did wrong?

Upvotes: 0

Views: 115

Answers (1)

Mat&#237;as Fidemraizer
Mat&#237;as Fidemraizer

Reputation: 64943

Check:

  • Have you added a reference to class library in the ASP.NET project?

  • I've never tried to re-use "asp" XML namespace. And I wouldn't recommend using it, because you can have naming collisions with Microsoft in the future, so, I'll suggest you to use a custom one, like "frm". As I've never tried to re-use "asp" namespace, maybe this is the reason of your control not being listed in the intellisense menu.

  • Is your class library target framework version the same of your ASP.NET application? If you're in 3.5, both must be for .NET Framework 3.5, or 4.0, and so on.

Just a try, comment out if non of these have solved your problem.

Upvotes: 1

Related Questions