How to put a Custom Control on the toolbox.

Discussion in 'ASP .Net' started by craigkenisston@hotmail.com, Sep 28, 2006.

  1. Guest

    I created a derived class from "Literal". I put the code in the
    App_Code folder and the control is working as expected.

    Now, I wan this control to be in the ToolBox, just like the others,
    what do I need to do ?
    Should it be in a separate library file to be able to get this ?

    Thanks in advance,
     
    , Sep 28, 2006
    #1
    1. Advertising

  2. You probably just need to add a "ToolboxData" attribute above the class
    definition. I don't have the syntax handy, but you can search it and find
    numerous examples.
    Peter

    --
    Co-founder, Eggheadcafe.com developer portal:
    http://www.eggheadcafe.com
    UnBlog:
    http://petesbloggerama.blogspot.com




    "" wrote:

    > I created a derived class from "Literal". I put the code in the
    > App_Code folder and the control is working as expected.
    >
    > Now, I wan this control to be in the ToolBox, just like the others,
    > what do I need to do ?
    > Should it be in a separate library file to be able to get this ?
    >
    > Thanks in advance,
    >
    >
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Sep 28, 2006
    #2
    1. Advertising

  3. Guest

    For what it said in the documentation, I think that attribute is for
    when you already have it in the Toolbox:

    "Specifies the default tag generated for a custom control when it is
    dragged from a toolbox in a tool such as Microsoft Visual Studio. "

    I'm talking about putting the custom control in the toolbox.

    Regards,






    Peter wrote:
    > You probably just need to add a "ToolboxData" attribute above the class
    > definition. I don't have the syntax handy, but you can search it and find
    > numerous examples.
    > Peter
    >
    > --
    > Co-founder, Eggheadcafe.com developer portal:
    > http://www.eggheadcafe.com
    > UnBlog:
    > http://petesbloggerama.blogspot.com
    >
    >
    >
    >
    > "" wrote:
    >
    > > I created a derived class from "Literal". I put the code in the
    > > App_Code folder and the control is working as expected.
    > >
    > > Now, I wan this control to be in the ToolBox, just like the others,
    > > what do I need to do ?
    > > Should it be in a separate library file to be able to get this ?
    > >
    > > Thanks in advance,
    > >
    > >
     
    , Sep 28, 2006
    #3
  4. Correct. If your control is built correctly, all you need to do is
    right-click on the Toolbox section where you want your control, choose
    "Add/Remove Items", and browse to your built control's assembly. In ASP.NET
    2.0, if the control project is in your Web Application, this happens
    automatically.

    Peter

    --
    Co-founder, Eggheadcafe.com developer portal:
    http://www.eggheadcafe.com
    UnBlog:
    http://petesbloggerama.blogspot.com




    "" wrote:

    >
    > For what it said in the documentation, I think that attribute is for
    > when you already have it in the Toolbox:
    >
    > "Specifies the default tag generated for a custom control when it is
    > dragged from a toolbox in a tool such as Microsoft Visual Studio. "
    >
    > I'm talking about putting the custom control in the toolbox.
    >
    > Regards,
    >
    >
    >
    >
    >
    >
    > Peter wrote:
    > > You probably just need to add a "ToolboxData" attribute above the class
    > > definition. I don't have the syntax handy, but you can search it and find
    > > numerous examples.
    > > Peter
    > >
    > > --
    > > Co-founder, Eggheadcafe.com developer portal:
    > > http://www.eggheadcafe.com
    > > UnBlog:
    > > http://petesbloggerama.blogspot.com
    > >
    > >
    > >
    > >
    > > "" wrote:
    > >
    > > > I created a derived class from "Literal". I put the code in the
    > > > App_Code folder and the control is working as expected.
    > > >
    > > > Now, I wan this control to be in the ToolBox, just like the others,
    > > > what do I need to do ?
    > > > Should it be in a separate library file to be able to get this ?
    > > >
    > > > Thanks in advance,
    > > >
    > > >

    >
    >
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Sep 28, 2006
    #4
  5. Guest

    Which control's assembly ?
    The code is part of the application. That _is_ my question.
    Do I need to have in a separated from the asp.net code, in its own
    class library ?
    Well, it seems yes.


    Regards,




    Peter wrote:

    > Correct. If your control is built correctly, all you need to do is
    > right-click on the Toolbox section where you want your control, choose
    > "Add/Remove Items", and browse to your built control's assembly. In ASP.NET
    > 2.0, if the control project is in your Web Application, this happens
    > automatically.
    >
    > Peter
    >
    > --
    > Co-founder, Eggheadcafe.com developer portal:
    > http://www.eggheadcafe.com
    > UnBlog:
    > http://petesbloggerama.blogspot.com
    >
    >
    >
    >
    > "" wrote:
    >
    > >
    > > For what it said in the documentation, I think that attribute is for
    > > when you already have it in the Toolbox:
    > >
    > > "Specifies the default tag generated for a custom control when it is
    > > dragged from a toolbox in a tool such as Microsoft Visual Studio. "
    > >
    > > I'm talking about putting the custom control in the toolbox.
    > >
    > > Regards,
    > >
    > >
    > >
    > >
    > >
    > >
    > > Peter wrote:
    > > > You probably just need to add a "ToolboxData" attribute above the class
    > > > definition. I don't have the syntax handy, but you can search it and find
    > > > numerous examples.
    > > > Peter
    > > >
    > > > --
    > > > Co-founder, Eggheadcafe.com developer portal:
    > > > http://www.eggheadcafe.com
    > > > UnBlog:
    > > > http://petesbloggerama.blogspot.com
    > > >
    > > >
    > > >
    > > >
    > > > "" wrote:
    > > >
    > > > > I created a derived class from "Literal". I put the code in the
    > > > > App_Code folder and the control is working as expected.
    > > > >
    > > > > Now, I wan this control to be in the ToolBox, just like the others,
    > > > > what do I need to do ?
    > > > > Should it be in a separate library file to be able to get this ?
    > > > >
    > > > > Thanks in advance,
    > > > >
    > > > >

    > >
    > >
     
    , Sep 30, 2006
    #5
  6. Sure, you would. Isn't that the basic idea of a custom control, that it
    should be re-usable across different applications? So you would have it in a
    separate project (which could be in the same solution as your current
    application).
    Peter

    --
    Co-founder, Eggheadcafe.com developer portal:
    http://www.eggheadcafe.com
    UnBlog:
    http://petesbloggerama.blogspot.com




    "" wrote:

    >
    > Which control's assembly ?
    > The code is part of the application. That _is_ my question.
    > Do I need to have in a separated from the asp.net code, in its own
    > class library ?
    > Well, it seems yes.
    >
    >
    > Regards,
    >
    >
    >
    >
    > Peter wrote:
    >
    > > Correct. If your control is built correctly, all you need to do is
    > > right-click on the Toolbox section where you want your control, choose
    > > "Add/Remove Items", and browse to your built control's assembly. In ASP.NET
    > > 2.0, if the control project is in your Web Application, this happens
    > > automatically.
    > >
    > > Peter
    > >
    > > --
    > > Co-founder, Eggheadcafe.com developer portal:
    > > http://www.eggheadcafe.com
    > > UnBlog:
    > > http://petesbloggerama.blogspot.com
    > >
    > >
    > >
    > >
    > > "" wrote:
    > >
    > > >
    > > > For what it said in the documentation, I think that attribute is for
    > > > when you already have it in the Toolbox:
    > > >
    > > > "Specifies the default tag generated for a custom control when it is
    > > > dragged from a toolbox in a tool such as Microsoft Visual Studio. "
    > > >
    > > > I'm talking about putting the custom control in the toolbox.
    > > >
    > > > Regards,
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > > Peter wrote:
    > > > > You probably just need to add a "ToolboxData" attribute above the class
    > > > > definition. I don't have the syntax handy, but you can search it and find
    > > > > numerous examples.
    > > > > Peter
    > > > >
    > > > > --
    > > > > Co-founder, Eggheadcafe.com developer portal:
    > > > > http://www.eggheadcafe.com
    > > > > UnBlog:
    > > > > http://petesbloggerama.blogspot.com
    > > > >
    > > > >
    > > > >
    > > > >
    > > > > "" wrote:
    > > > >
    > > > > > I created a derived class from "Literal". I put the code in the
    > > > > > App_Code folder and the control is working as expected.
    > > > > >
    > > > > > Now, I wan this control to be in the ToolBox, just like the others,
    > > > > > what do I need to do ?
    > > > > > Should it be in a separate library file to be able to get this ?
    > > > > >
    > > > > > Thanks in advance,
    > > > > >
    > > > > >
    > > >
    > > >

    >
    >
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Sep 30, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Prasanna Padmanabhan

    add custom control to toolbox

    Prasanna Padmanabhan, Jul 3, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    3,648
    Prasanna Padmanabhan
    Jul 3, 2003
  2. Showjumper
    Replies:
    2
    Views:
    2,406
    Benjie Fallar
    Jul 18, 2003
  3. Showjumper
    Replies:
    2
    Views:
    2,373
    Showjumper
    Jul 22, 2003
  4. Erik Cruz

    Custom control and toolbox tabs

    Erik Cruz, Jan 17, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    469
    Mohammad A. Samara
    Jan 17, 2004
  5. JB
    Replies:
    1
    Views:
    554
Loading...

Share This Page