0

Hi,

Im trying to convert my UserControls to be sharable across multiple projects.

I have read up on this, and it seems that I need to have all code in one file (i.e. in the .ascx, rather than codebehind/designer) so I am trying to do this:

<%@ Control Language="C#" AutoEventWireup="true" ClassName="ImageButton" Inherits="Button" %>
<%@ Register src="Button.ascx" tagname="Button" tagprefix="MIKE" %>
<script runat="server">
        protected override void OnInit(EventArgs e)
        {
            this.ImageTag.Src = ImageStartPath + "/" + ImgSrc + "_Up.png";
            base.OnInit(e);
        }
...

the problem is, that despite the "Inherits" attribute on the <%@ Control tag, set to "Button", which is the base class im trying to inherit from, I can't get the base class of my ImageButton class to be Button, it just stays as the basic UserControl, which is a problem, because I am trying to inherit some properties from the base class...

Any ideas?

Thanks,

Mike

3
Contributors
5
Replies
7
Views
6 Years
Discussion Span
Last Post by __avd
0

If you are wanting a control to inherit from button it sounds more like you're needing to create a custom server control rather than a user control. To do this you'll need to create a new project using ASP.NET Server Control as the project type. If you goole "ASP.NET custom control" or "ASP.NET composite control" you'll find a lot of tutorials/information covering this topic in more detail.

0

Hi

I have read through those posts and they're really useful, so thanks!

I am still having problems with how to inherit though as none of those links cover anything like that.

Ideas?

Thanks,

Mike

Edited by mikesowerbutts: n/a

0

hi, just to clarify, im looking for the equivalent of:

public partial class ImageButton : Button

in a single .ascx page, which i thought would be:

<%@ Control Language="C#" AutoEventWireup="true" ClassName="ImageButton" Inherits="Button" %>

But it doesnt seem to be...

Mike

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.