.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
ASPEvil
Ashutosh Jha
Jean Paul
satyapriyanayak
SP
Post New Web Links

Custom Controls in C# .NET

Posted By: Amit Mehra     Posted Date: October 14, 2009    Points: 2   Category :C#
 
Embedding user controls in a Windows form is just like adding a simple button or text box that are already provided with .NET. These basic controls were written essentially like you code your own controls. Typically the controls you design are to be used in multiple forms or to modularize your code. These reasons help reduce the amount of code you have to type as well as make it easier for you to change your implementation. There should almost never be any reason to duplicate code because it leaves a lot of room for bugs. So, implementing functionality specific to your control in the control's source code is a good idea. This reduces code duplication as well as modularize your code, which is a good programming guideline.


View Complete Post


More Related Resource Links

Wicked Code: Craft Custom Controls for Silverlight 2

  

If you're unfamiliar with Windows Presentation Foundation (WPF), building that first Silverlight custom control can be a daunting experience. This article walks through the process.

Jeff Prosise

MSDN Magazine August 2008


UI on the Fly: Use the .NET Framework to Generate and Execute Custom Controls at Run Time

  

Creating UI controls on the fly can be accomplished via run-time code generation. And there are lots of reasons to do so. Generating these controls once and then reusing them as needed is more efficient than generating the controls each time. Read on.

Morgan Skinner

MSDN Magazine December 2005


ASP.NET 2.0: Personalize Your Portal with User Controls and Custom Web Parts

  

ASP.NET 2.0 introduces a Web Part control that is designed to deal with the serialization, storage, and retrieval of customization and personalization data behind the scenes. In this article, the authors explain how you can put the WebPart control to work in your ASP.NET 2.0 applications.

Ted Pattison and Fritz Onion

MSDN Magazine September 2005


Custom controls and ViewState management issue

  

Hi,

I want to know that when we create custom controls, then is there State Management through ViewState done automatically or we have to handle it explicitely ?Since i have created Custom Controls that is behaving as if it is not maintaining its state on PostBack.


How to add designing in Custom Controls ?

  

Hi ,

I am trying to create Custom control. I have created simple TextBox, Label, Buttons  etc. and added my own logic for their working,  but i want to add  some designing to that controls.I tried to add CSS file for that from the Add New Item, but there is no list for CSS. 

I added forcefully but it is not supporting CSS files.It seems that Custom controls does not support designing and layout through CSS.

Can you tell how can i polish my controls with beautiful designing and layouts ?


Creating Custom SharePoint 2010 Field Types and Controls with Visual Studio 2010 and Silverlight 3

  
Learn how developers can create rich experiences in SharePoint Server 2010 publishing sites using Microsoft Silverlight 3.

Video: Creating Custom SharePoint 2010 Field Types and Controls with Visual Studio 2010 and Silverli

  
Watch the video that accompanies the MSDN article and learn how developers can create rich experiences in SharePoint Server 2010 publishing sites using Microsoft Silverlight 3.

Cannot set custom attributes on mobile controls in this page

  

Hello,

I am beginner at mobile Pages with ASP.NET. And i want to make an application with contains  a few TextBox that have different size.

it's my sample code here:



<%@Page Inherits= "System.Web.UI.MobileControls.MobilePage" Language= "C# " %>
<%@ Register TagPrefix= "Mobile" Namespace= "System.Web.UI.MobileControls " Assembly= "System.Web.Mobile" %>
<Mobile:Form runat="server" id="form1" Paginate="true" >
<Mobile:Panel Paginate="True" runat=&

Developing custom controls literature

  
Hi, I'm looking for some literature which focus on developing custom controls in WPF. It should explain how to develop custom controls in details. It should tell me how to chose which control is the best start point for developing custom control which fits my needs. Next, for example if my new custom control need to be inherited from ItemsControl which methods I should override and what is their purpose, what else I should do etc. What do you recommend? Thanks in advance. Nikola  

Custom panel - missing design time support for controls.

  
I’m trying to implement a custom panel, one that will behave kind of like the standard Canvas panel. The implementation is done and it is working when I add components in the xaml, but what is not working is move and resize of components in the designer. In the designer each component shows the ‘selected frame’ when selected, but it cannot be moved or resized. Can someone point me to what I’m missing, or an article that describes how do add this support?.   The reason I’m not deriving from the existing Canvas is mainly because I want to understand how it works and how to implement it manually.   Thanks  

Issue with Custom Controls

  
Hi,we are facing a page loading  problem with custom controls only IE browser. but that the same page open on mozilla firefox 3.5.  we are using all the controls on the page are custom controls. I pasted on custom control code bellow, please verify that is it written proper or not...  using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Web.UI.Design; using System.IO; using System.Configuration; using System.Web.UI.WebControls.WebParts; using System.Drawing.Design; using System.Data; namespace Ays4.Web.UI { #region class CustomizeTextBox [ToolboxData("<{0}:CustomizeTextBox runat=server></{0}:CustomizeTextBox>")] [Designer("System.Web.UI.Design.ReadWriteControlDesigner, System.Design")] [PersistChildren(true)] [ParseChildren(false)] public class CustomizeTextBox : WebControl, INamingContainer { #region Attribute private validateType.ValidationType _ValidationType = validateType.ValidationType.None; private TextBoxType.Mode _Mode = TextBoxType.Mode.None; HtmlTable mainTable; string strJs = ""; private TextBox _inputControl; strin

Controls Disappear in Custom Control Design View

  
I have a site using eight (so far) custom web user controls  and two of them have started misbehaving in design view.  When designing the control itself some (in one control) or all (in the other) regular controls (labels, text boxes, etc.) disappear from the design view surface.  They can still be seen in the source view and if the control is hosted on a regular .aspx page the control displays properly.  The code window recognizes all controls in the objects dropdown list and I can write appropriate code.  The controls run properly on their hosted pages.  If I switch to Split view and select controls in the source view panel a very small area od the design surface becomes selected (like one pixel for any of us who remember programming old DOS applications with 80-column screens) but no controls can be seen. In short, the controls work in every respect except that I cannot see all or part of the design surface in Design view when editing the controls directly.  I've double-tripple checked the source code for anything that may be causing this and just don't see anything.  (The controls aren't that complicated.)

Isseus with Custom Button Controls

  
Hi I have inherited a custom button control which was originially derived from a LinkButton, however due to some isseus with the click event and different browsers it has been decided to use a control derived from a Button. I have the following issues with this: 1) The text appears with a box around it whereas the original didn't have this (see example below) 2) When i position the cursor over the button it correctly changes colour but the text disappears whereas the original it remains. Any help on this would be appeciated, I have attached my code and css files Regards Kenpublic class GemaButtonControDesigner : ControlDesigner { public override string GetDesignTimeHtml() { GemaButton control = this.ViewControl as GemaButton; string rtr = control.Text; if (String.IsNullOrEmpty(rtr)) rtr = "GemaButton"; return rtr; } } [ParseChildren(true, "Text")] [Designer(typeof(GemaButtonControDesigner))] [DefaultProperty("Text")] [ToolboxData("<{0}:GemaButton runat=\"server\"></{0}:GemaButton>")] public class GemaButton : Button { #region Constants private const int MINIMUM_SIZE = 16; private const int SMALL_SIZE = 79; private const int DEFAULT_SIZE = 97; private const int SMALL_HEIGHT = 10; private const int DEFAULT_HEIGHT = 14;
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend