Last post Jun 03, 2009 02:29 PM by Nowman
May 29, 2009 03:02 PM|Nowman|LINK
I want to create a web user control that works exactly like another web conrol, let's say LinkButton, but has a few more properties. What is the best way to go about this, know of any good links? thanks.
May 29, 2009 06:28 PM|Slipperman|LINK
if i understand correctly, you may need to create your own custom control first. pretty easy..
create a new class library project and name it MyLinkButton (or whatever)
in the cs or vb file, have your class derive from LinkButton
add your properties
since this creates a registered dll/toolbar item, you should be able to add it to an ascx file directly from the toolbar. but if that's all you're using the ascx for, you might as well use your control straight up (ie: put it on directly on an aspx page).
hope i understood you correctly.
Jun 01, 2009 09:02 AM|AbsurdParadigm|LINK
I think what he wants is actually what I'm wanting to know also.
I think he wants to be able to just drop LinkButton on a page and have it use the new functionality he's written. This is what I want also. I want to be able to write a class that extends LinkButton and then effectively replaces it with the new extended
web control so that new functionality is added every time.
Does anyone know how to do this?
Jun 01, 2009 01:50 PM|Slipperman|LINK
"I want to be able to write a class that extends LinkButton and then effectively replaces it with the new extended web control".
to me, writing your own class that extends an existing class is called inheritance which is pretty much what i said. using inheritance, your new class will take on all the functionality of the base class (LinkButton) and still allow you to add your own properties,
sorry if you already knew that but i don't think there's really another way for you to do what you seem to be asking.
Jun 02, 2009 02:53 PM|Nowman|LINK
Right I know all about inheritance, that is no problem. Once I have that class created I am having issues dropping that control on the page.
Jun 02, 2009 03:48 PM|Slipperman|LINK
i was responding to Absurd (i quoted him and responded to that)
so are you seeing the control in the toolbar when you try to plop it on the aspx or is it not there at all? if it is, does it blow up after you place it on the form? may need more info like what error you are getting, etc
if it isn't, add a web application project (with a default.aspx) to your solution so that you now have the class library and the web app together in the same solution. bring up default.aspx in the designer and see if your control shows up in the toolbar
Jun 03, 2009 02:29 PM|Nowman|LINK
Yea I figured it out. I just was use to registering .ascx web user controls and never registered one with the namespace.