user control in asp.net

Posted by Sheeba under ASP.NET on 11/1/2010 | Points: 10 | Views : 3192 | Status : [Member] | Replies : 4
Hi

What is usercontrol?What are the advantages and how to create the control?

Give me brief explanation with some examples...


Thank you




Responses

Posted by: SheoNarayan on: 11/1/2010 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
User control is an asp.net like page that works most like asp.net page and you can keep everything that you keep in your asp.net page. This is generally used to keep a portion of page that can be reused on different pages. For example, Header, Footer, Menus etc. You can keep menus in the user control and use it in all your content pages. User control helps you to reuse the stuffs.

To create a user control, right click the folder where you want to add user control and click on Add New Item ..., Select Web User Control from the template list and give proper name. Click Add. Keep something (asp.net controls, html controls etc.) there.

To use the user control, you need to add the Register Directives at the top of your content or master page like below
<%@ Register TagName="Footer" TagPrefix="Main" Src="~/Include/myuserControl.ascx" %>
and then you need to use the tag you mentioned in Register directives where you want your control to appear on the page.
<Main:Footer runat="server" id="f1" />

You are done!, hope this will help you.

Thank you for asking.

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Sheeba, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: T.saravanan on: 11/1/2010 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi sheeba,

User Control means to add the more functions and properties to the control.For example if we using normal TextBox control means its allow numeric and character also.But that control only allow numeric value means we can add some functions to create new control.
Just use that control where we want numeric value in that place

Disadvantage:
If using a user control means we can use that control in that project only not more than a project.

For your reference...

http://www.15seconds.com/issue/010504.htm

http://www.codersource.net/asp-net/asp-net-advanced/creating-a-web-user-control-in-c.aspx

http://www.codeproject.com/KB/user-controls/myusercontrol.aspx

Cheers :)

Thanks,
T.Saravanan

Sheeba, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prasham on: 11/5/2010 [Member] Starter | Points: 25

Up
0
Down
Hello,

An user control is a composite control, can be created by using existing web server/HTML controls. User controls can be added on asp.net web page, SharePoint master page, page layout and webparts. User controls has there own UI and code. The extension for the user control is .ascx.

Following are some good links:

http://msdn.microsoft.com/en-us/library/fb3w5b53.aspx
http://www.15seconds.com/issue/020319.htm
http://www.codeproject.com/KB/user-controls/myusercontrol.aspx

Thanks and Best Regards
Prasham

Sheeba, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lalji_mer on: 11/9/2010 [Member] Bronze | Points: 25

Up
0
Down
User control is powerful functionality of ASP.NET. With the help of the user control you can reuse the Design as well as code in the application. Developing User control is similar to developing form in ASP.NET. User control is created in markup file with .ascx extension.

Check here how to create user control
http://www.c-sharpcorner.com/UploadFile/jayendra/528/

more information will get here
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/userctrl/default.aspx
http://asp.net-tutorials.com/user-controls/using/

LP MER

Sheeba, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response