Developing a Custom Web Control (ASP.NET 2.0)
Author:Robert PostAt:Wed, 26 Nov 2008 10:34:48 GMT Posted In:Custom Controls
Q:Hello, I'm making a whole bunch of website components (news system, screenshot viewer, etc) that I want to be able to use across multiple websites with ease.
First question:
1. How do I create a custom web control? I created a new project in Visual Studio 2005, but i'm not sure I understand it 100%. I already wrote the code, and it's working (I wrote it as a normal ASP.NET page). Can I simply convert that to a user control? How can I do this easily?
2. Is it possible to place all the DLLs in one folder on my server, and make the ASP.NET app access them instead of its own "\bin"\?
Thanks =)!
First question:
1. How do I create a custom web control? I created a new project in Visual Studio 2005, but i'm not sure I understand it 100%. I already wrote the code, and it's working (I wrote it as a normal ASP.NET page). Can I simply convert that to a user control? How can I do this easily?
2. Is it possible to place all the DLLs in one folder on my server, and make the ASP.NET app access them instead of its own "\bin"\?
Thanks =)!
A:
Try File->New Project -> Class Library.
All Your classes should inherit from WebControl.
Yes. When You compile the project in bin folder You`ll find a dll file. put it to GAC and the problem solved.
orzeh
Try File->New Project -> Class Library.
All Your classes should inherit from WebControl.
Yes. When You compile the project in bin folder You`ll find a dll file. put it to GAC and the problem solved.
orzeh
A:
If you have code in an ASPX that you want to move into a User Control you can do so by adding a new User Control to your project and copying the code into that new control. One big difference between an ASPX and a User Control is that a User Control doesn't have form tags <form>. User controls are reusable within you web application while custom server controls are reusable within many web apps.
A:
If you decide to build a custom control you can register the assembly (.dll) in the GAC as mentioned by Oezeh. To do so you will need to use gacutil /i AssemblyFileName.dll
http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=713 has a great tutorial on registering an Assembly in the GAC.
A:www.learnvisualstudio.net has a great video tutorial of putting an assembly (.dll) in the GAC. See a pro do the job before your very eyes!
This is a pay site but the price is worth it considering all the video material there.
This is a pay site but the price is worth it considering all the video material there.
Previous: User Control Validation
I created a user control with form fields (name, address, city, state, etc.) I dropped two user controls on one page, one for Shipping, and the other for Billing. I have validation within this user control, but they fire twice. If I fill in Shipping's address and not Billing's... more
Next: NoneRandom Recommend
- Custom control not working properly
- Loosing state when postbacking
- What's wrong with my self validating TextBox Control?
- Error With Button Control Enum Variable
- Adding a control dynamically in the onLoad function of a custom control
- Control cannot be cretaed because Visual Studio cannot find the controls type in the control assembly
- how to get reference to parent page and/or parent user control
- How to prevent base control from being added to ToolBox?
- Simple EmailAddress Textbox custom control
- Embed AjaxControlToolkit dll in a control?
Rss Feed