C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » ASP.NET/Web Applications »

User Controls


Posted Date: 17 Mar 2004    Resource Type: Articles    Category: ASP.NET/Web Applications
Author: KasiviswanathMember Level: Gold    
Rating: 1 out of 5Points: 5



The User control is a Web based control, introduced by .net. Using this we can easily create your own custom, reusable controls. The user controls are compiled, when first requested and stored in server memory to reduce the response time for subsequent requests.

To create a user control, create a new file and give it a name with the extension .ascx.

Sample Code



< %@ Register TagPrefix="Acme" TagName="Login"
Src="Loginmenu.ascx" %>

< html>

< script language="VB" runat="server">

Sub Page_Load(Sender As Object, E As EventArgs)

If (Page.IsPostBack)
lbl1.Text &= "UserId" & Login.UserId & "< br>"
lbl1.Text &= "Password" & Login.Password & "< br>"
End If
End Sub

< /script>
< body>
< h3>User Control for Loginpage< /h3>
< form runat="server">
< Acme:Login id="Login" UserId="Test Spider" Password="test"
BackColor="beige" runat="server"/>
< /form>
< asp:Label id="lbl1" runat="server"/>

< /body>
< /html>




Calling User control from .aspx page




< %@ Page Language="vb" Codebehind="Callingusercontrol.aspx.vb"
Inherits="WebApplication.Callingusercontrol" %>

< %@ Register tagname="menu" tagprefix="uctrl" src ="Loginmenu.ascx" %>





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Cookie in ASP.NET
Previous Resource: Images From Your Database To Response
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET/Web Applications


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use