Dear friends,
How to add User controls in 3.5 give one example
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
SenthilkumarPosted Apr 16, 2012, 11:52 PM
The web user control is a separate page and it will be used to create the partial of page in the web pages. It can't run independentely.
It has the extension name of (.ascx) and can be add in the "Add new Item".
As you can see in the web page, the header, footer or custom page control can be created in the web user control and can be added to the page using the register directives.
It has to be added for every application which want to use the web user control and once registered in the web page can be create the multiple instances as well.
Please follow this link for steps.
http://msdn.microsoft.com/en-us/library/26db8ysc(v=vs.85).aspx
http://asp.net-tutorials.com/user-controls/using/
Satyapriya NayakPosted Apr 16, 2012, 4:55 AM
To create an instance of a user control programmatically
In the user control, be sure that the @ Control directive contains a ClassName attribute that assigns a class to the user control.
The following example sets the ClassName attribute to strongly type a user control.
In the page where you want to work with the user control, create a reference to the user control with the @ Reference directive.
When you create the user control programmatically, the strong type for your user control is available to the ASP.NET Web page only after you have created a reference to it. For example, the following code creates a reference to a user control created in the MyUserControl.ascx file.
Create an instance variable for the user control, using the control's class name. The class will be part of the ASP namespace.
For example, if you want to create an instance of the user control declared as class Spinner, you use syntax such as the following:
Create an instance of the user control in code by calling the LoadControl method.
Assign property values as necessary, and then add the control to the ControlCollection collection of a container on the page, such as a PlaceHolder control.
The following example shows an ASP.NET Web page that loads a user control programmatically. The page includes an @ Reference directive to specify the control's file. The LoadControl method reads the file and instantiates it as a control that can be added to the page.
Also Please refer the below links
http://msdn.microsoft.com/en-us/library/c0az2h86.aspx
http://www.c-sharpcorner.com/uploadfile/jayendra/how-to-create-user-control-in-Asp-Net/
Thanks