locked
How to develop custom web server control in visual studio 2005 RRS feed

  • Question

  • User-1854646908 posted

    Hi guys,

    I want to develop custom web server control in visual studio 2005,

    When i open new project and start it, i cannot reach to Design View inside the project to add controls from ToolBox

    There is

    WebControlLibrary1 class only.

    What is the poblem please

    Sunday, April 24, 2011 10:04 PM

Answers

  • User3866881 posted

    Hi:)

    It seems that you've mixed the concepts of Developing Server-side control with the template in the VS and customized control (*.asx).

    Generally speaking. A Server-side control is very normal, which can be published and added into the ToolBox. It has no design view for you to develop by "dragging and dropping" so easily. You have to handle proper events as well as to write down codes and then compile the control, and then you should apply it by dragging and dropping into the aspx page. Thus you can see what it looks like. (This is a torturial:http://msdn.microsoft.com/en-us/library/zt27tfhy.aspx)

    Here's the template:

    Compares with this, a customized control is much easier, it is based on an existing project, you can right click the proj and add "Web User Control" into the proj, and then you can switch between design mode and code mode to view, to see what's happening when coding. And you can drag and drop the control into the existing page to test it to see the result. (Torturial:http://msdn.microsoft.com/en-us/library/3457w616(v=vs.71).aspx)

    Here's it:

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 26, 2011 9:04 PM
  • User1759999623 posted

    While I sounds like that you're looking for a web user control, which can be developed just like a web page, you are probably wanting a custom server control.  The distinction between them is that the user control is created using an ASCX file with code-behind while a custom server control is strictly code contained in a class library.  The benefit of the server control is that it is more portable than the user control as the server control's library can be compiled independent of any specific application and then added to a number of different projects.

    So, what type of control are you actually looking for?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 27, 2011 9:18 AM

All replies

  • User1759999623 posted

    There is no problem.  When creating a custom server control, you will need to use all code since this is essentially a class.  There is no designer involved in creating a custom server control.  Additionally, you would typically not add other controls unless you are building a composite control.

    Now, if you want to create a user control, then you would be able to use the designer for this.  Is this what you really looking to build?

    Sunday, April 24, 2011 10:48 PM
  • User-1854646908 posted

    Thanks man,

    In fact, i have a dream that i want to make custom control that display the UserName when user signed in to the website,

    and when user click on it, menu dropdown and show links like: Inbox,Account,My Bookmarks,...... ect.

    Like that custom control on www.youtube.com and many other websites.

    can u help me man or tell me about article explain how to do this project please.

    thanks.

    Tuesday, April 26, 2011 1:44 AM
  • User3866881 posted

    Hi:)

    It seems that you've mixed the concepts of Developing Server-side control with the template in the VS and customized control (*.asx).

    Generally speaking. A Server-side control is very normal, which can be published and added into the ToolBox. It has no design view for you to develop by "dragging and dropping" so easily. You have to handle proper events as well as to write down codes and then compile the control, and then you should apply it by dragging and dropping into the aspx page. Thus you can see what it looks like. (This is a torturial:http://msdn.microsoft.com/en-us/library/zt27tfhy.aspx)

    Here's the template:

    Compares with this, a customized control is much easier, it is based on an existing project, you can right click the proj and add "Web User Control" into the proj, and then you can switch between design mode and code mode to view, to see what's happening when coding. And you can drag and drop the control into the existing page to test it to see the result. (Torturial:http://msdn.microsoft.com/en-us/library/3457w616(v=vs.71).aspx)

    Here's it:

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 26, 2011 9:04 PM
  • User1759999623 posted

    While I sounds like that you're looking for a web user control, which can be developed just like a web page, you are probably wanting a custom server control.  The distinction between them is that the user control is created using an ASCX file with code-behind while a custom server control is strictly code contained in a class library.  The benefit of the server control is that it is more portable than the user control as the server control's library can be compiled independent of any specific application and then added to a number of different projects.

    So, what type of control are you actually looking for?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 27, 2011 9:18 AM