locked
Extend Web Control RRS feed

  • Question

  • User355672401 posted

    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.

    Friday, May 29, 2009 3:02 PM

Answers

  • User192013029 posted

    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.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 29, 2009 6:28 PM
  • User1155910849 posted

     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?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 1, 2009 9:02 AM
  • User192013029 posted

    "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, methods, etc.

    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.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 1, 2009 1:50 PM
  • User192013029 posted

    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 then.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 2, 2009 3:48 PM

All replies

  • User192013029 posted

    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.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 29, 2009 6:28 PM
  • User1155910849 posted

     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?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 1, 2009 9:02 AM
  • User192013029 posted

    "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, methods, etc.

    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.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 1, 2009 1:50 PM
  • User355672401 posted

    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.

    Tuesday, June 2, 2009 2:53 PM
  • User192013029 posted

    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 then.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 2, 2009 3:48 PM
  • User355672401 posted

    Yea I figured it out.  I just was use to registering .ascx web user controls and never registered one with the namespace.

    Wednesday, June 3, 2009 2:29 PM