Creating a Custom Web Server Control
The Custom Web server controls are classes,and they can be compiled into their own assemblies or included in a larger assembly with other controls and classes used by your application.
One of the first steps in the development process is to decide from which class you will derive your control.If the controil is very similar to an existing Web Server Control,such as a text box with some extra functionality,your control could inherit from that control.You typically override the Render method to modify the HTML that is sent to the browser.If your control will have entirely new functionality,you should derive it from the Control class
Adding Custom Web Control in Page
To use a Web server control on a Web Page,add a <%@ Register %> directive to the page,as in the following example:
<%@ Register TagPrefix = " MySite " Namespace = " MySiteControls .Controls " %>
Alternatively,you can register the control in the Web.Config file for the application,using the
< control > tag.In this way ,you can register the control for all pages in the applicatio
< system.web >
< pages >
< controls >
< add tagPrefix = " MySite " Namespace = " MySiteControls .Controls " />
</ controls >
</ pages >
</ system.web >
When the control is registered,it can be used on the Web page as like;
< MySite : ProductSelector id = "ProductSelector1" runat = "server" />
The Custom Web server controls are classes,and they can be compiled into their own assemblies or included in a larger assembly with other controls and classes used by your application.
One of the first steps in the development process is to decide from which class you will derive your control.If the controil is very similar to an existing Web Server Control,such as a text box with some extra functionality,your control could inherit from that control.You typically override the Render method to modify the HTML that is sent to the browser.If your control will have entirely new functionality,you should derive it from the Control class
Adding Custom Web Control in Page
To use a Web server control on a Web Page,add a <%@ Register %> directive to the page,as in the following example:
<%@ Register TagPrefix = " MySite " Namespace = " MySiteControls .Controls " %>
Alternatively,you can register the control in the Web.Config file for the application,using the
< control > tag.In this way ,you can register the control for all pages in the applicatio
< system.web >
< pages >
< controls >
< add tagPrefix = " MySite " Namespace = " MySiteControls .Controls " />
</ controls >
</ pages >
</ system.web >
When the control is registered,it can be used on the Web page as like;
< MySite : ProductSelector id = "ProductSelector1" runat = "server" />
No comments:
Post a Comment