Setting properties for ASP.NET Custom Server Controls

The server controls that you see in the IDE are all custom controls only. These are well thought and built by Microsoft and are registered for the IDE. They work very well and interact with each other efficiently.

You can also create such custom control. It is actually a compiled class. The custom control is created programmatically instead of using the IDE’s design page. You can create any complex feature as a custom control and use it on a page. You can define the properties for such a custom server control.

You can use the get and set routines to access the properties and to set them. For example the following code is used to set the property Title in a custom server control.

Public Property Title() As String
Get
Return lblTitle.Text
End Get
Set(ByVal titleValue As String)
lblTitle.Text = titleValue
End Set
End Property

Similarly you can create any number of properties for your custom control. You can also use an attribute called "ToolboxData" to set how it is rendered when the custom control is dragged and dropped in to the designer area. This is used to specify the tag that you want to be displayed and the default value that is to be displayed in the code behind.





______________________________________________________

Recommended Resource



| Why should you go for Server Controls | Advantages of using .NET Server Controls | Understanding ASP.NET Server Controls | Creating Web Server Controls | Server Side Controls in ASP.Net | Creating Custom Server Controls | Server Controls in ASP.NET Web Page | Using Html Server Controls in your Web Pages | Understanding Dynamic Server Controls in ASP.NET | Using ASP Server Controls Templates | Developing ASP.NET Server Controls | Setting properties for ASP.NET Custom Server Controls | Implementing ASP.NET Server Side Controls | Creating Professional ASP.NET Server Controls |

 

“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”

| Privacy Policy for www.dotnet-guide.com | Disclosure | Contact |

Copyright - © 2004 - 2024 - All Rights Reserved.